【发布时间】:2011-12-06 21:21:33
【问题描述】:
我如何排除我的脚本正在执行的操作而只打印 echo 的内容?
例如,我正在对一个目录进行 taring,我不希望它 tar 的每个文件都回显。只有回显命令。
#! /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/
【问题讨论】:
-
如果你不想 tar 发出输出,你为什么要传递它 -v?
-
我不明白的是:为什么要使用三个步骤?
tar -C ~/LegendaryXeo/html/ --exclude=".git" -cf - . | tar -C ~/LegendaryXeo/work/ -xf - && scp -r ~/LegendaryXeo/work/* user@site:~/../../domains/。 tar 部分将在没有 tmep tar 文件的情况下使用。如果您不需要工作目录的内容,您应该使用 ssh 一步完成此操作,例如 ``tar -C ~/LegendaryXeo/html/ --exclude=".git" -cf - 。 | ssh user@site "tar -C ~/../../domains/` -xf -"