带有条件回声的Shell脚本

Xeo*_*Xeo -6 bash shell terminal

如何排除我的脚本正在执行的操作并且只有echo的打印?

例如,我正在尝试一个目录,我不希望它的所有文件都回显...只有echo命令.

#! /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/
Run Code Online (Sandbox Code Playgroud)

aio*_*obe 5

将输出重定向tar/dev/null:

tar [your options] [files] &> /dev/null
Run Code Online (Sandbox Code Playgroud)

echo脚本中的任何命令仍将输出到屏幕.