Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试使用复制的脚本,其中包括以下命令
echo "rc $2" > $WORKDIR/out.dat
我猜它会尝试将一些内容输出到文件 out.dat。但是“rc $2”是什么意思呢?
它还包括
echo "PWD" >> $WORKDIR/env.txt
为什么它在这里使用 >> 而不是 >
$2是执行脚本时的第二个传入 var。
$2
例子:
./script.sh foo bar # $2 would be bar
>>表示追加到文件而不是完全覆盖文件。
>>
“rc”在这里没有任何意义,“PWD”也没有。它们只是字符串。不过,它们可能意味着 out.dat 和 env.txt 中的某些内容。"$2" 是对用于调用脚本的第二个参数的引用。
>>意味着附加到文件而不是像>将做的那样覆盖它。
>