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.
我正在 bash 中制作一个需要复制文件的脚本。我尝试使用设置cp了标志的命令,-n但我发现在某些系统上该-n标志不可用。
cp
-n
cp: invalid option -- n
我希望这个脚本足够便携,这样用户就不需要更新他们的cp.
该-n标志的作用是仅从源中复制尚未在目标中的文件而不提示。
有没有替代方案?
If the -i flag is available, yes n | cp -i ... should achieve the same as cp -n ....
-i
yes n | cp -i ...
cp -n ...
Try rsync -u. Although is not exactly equivalent to cp -n, it may be what you actually want...
rsync -u
cp -n