我需要一些帮助来理解给定 shell 脚本的以下几行。
这里$_filecount
变量保存了要归档的文件数
我想知道$TARC
是什么意思,搜索了这个命令,但没有得到TARC
和TARU
命令的结果。谁能给我解释一下这些命令是什么
_archive=${ARCHIVE_PATH}/${_name}_$(hostname)_${_today}.tar
if [ $_filecount -ne 0 ]; then
if ! [ -f ${_archive} ]; then
touch ${ARCHIVE_PATH}/${_today}
$TARC ${_archive} -C ${ARCHIVE_PATH} ${_today}
rm -f ${ARCHIVE_PATH}/${_today}
fi
for i in ${_filelist}; do
$TARU ${_archive} -C ${_path} $i
[ $? -eq 0 ] && rm -f ${_path}/$i
done
fi
当使用 cygwin
在 $TARC ${_archive} -c ${ARCHIVE_PATH} ${_today}
行运行此代码时,返回以下错误
tar: invalid option -- 'E'
Try `tar --help' or `tar --usage' for more information.
在此先感谢您的帮助
最佳答案
$TARC
和 $TARU
是变量(如果它们没有在你的脚本某处定义,那么它们一定是环境变量)
尝试echo $TARC
看看它们被设置成什么。
看起来 TARC 是用于归档的 tar 命令,而 TARU 是用于取消归档的 tar 命令。
TARC 和 TARU 必须在某处设置,否则您会得到不同的错误 - 您看到的错误是特定于 tar 的。
关于linux - 这个 shell 脚本代码是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10680813/