linux - 这个 shell 脚本代码是什么意思

标签 linux bash shell unix tar

我需要一些帮助来理解给定 shell 脚本的以下几行。

这里$_filecount变量保存了要归档的文件数

我想知道$TARC 是什么意思,搜索了这个命令,但没有得到TARCTARU 命令的结果。谁能给我解释一下这些命令是什么

_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/

相关文章:

regex - Unix find 不尊重正则表达式

linux - 拥有 root 用户的进程是否始终拥有 Linux 中可用的所有功能?

windows - Cygwin .sh 文件作为 Windows 任务计划程序运行

shell - 从文件读取时 exec 命令的重要性

linux - Linux系统上的cilk++

c - 在 C 语言中使用 setenv()

bash - 想要在 unix 中执行 tail 命令后退出

linux - 在 bash 脚本中循环直到完成其他一些任务(从 nohup 开始)?

node.js - Mac-bash : node: command not found

linux - 需要一些帮助编写 shell 脚本来添加数字