开发者

Shell Scripts with conditional echos

开发者 https://www.devze.com 2023-04-12 14:14 出处:网络
How do I exclude what my script is doing and only hav开发者_Python百科e echo\'s print? For instance, i am taring a directory and I don\'t want every file it tar\'s to echo.. only the echo command.

How do I exclude what my script is doing and only hav开发者_Python百科e echo's print?

For instance, i am taring a directory and I don't want every file it tar's to echo.. only the echo command.

#! /bin/bash 

clear

echo "Compressing the files"

cd ~/LegendaryXeo/html/
tar --exclude=".git" -cvf site.tar *
mv site.tar ~/LegendaryXeo/work/
cd ~/LegendaryXeo/work/

clear

echo "Extracting the site"

tar -xvf site.tar 

echo "Deleting Tar"

cd ~/LegendaryXeo/work/

rm -f site.tar

clear

echo "Copying files to server"

scp -r ~/LegendaryXeo/work/* user@site.com:~/../../domains/


Redirect the output of tar to /dev/null:

tar [your options] [files] &> /dev/null

Any echo command you have in your script will still output to the screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消