带有条件回显的 Shell 脚本
如何排除我的脚本正在执行的操作并且只有 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/* [email protected]:~/../../domains/
How do I exclude what my script is doing and only have 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/* [email protected]:~/../../domains/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
tar
的输出重定向到/dev/null
:脚本中的任何
echo
命令仍会输出到屏幕。Redirect the output of
tar
to/dev/null
:Any
echo
command you have in your script will still output to the screen.