[英]What's the DRYest way to replace a file with a symlink in bash
I have an existing file which I'm replacing with a symlink to another file. 我有一个现有的文件,我用一个符号链接替换另一个文件。 So I basically need to do this:
所以我基本上需要这样做:
rm orig
ln -s /var/better orig
I DRYed the above to this: 我把上面的内容干掉了:
{rm,ln\ -s\ /var/better}\ orig\;
But it no longer works. 但它不再有效。 The shell now complains:
shell现在抱怨:
-bash: rm orig;: command not found
Is there a way to make the DRY form work? 有没有办法让DRY表格有效?
You can just use "-f". 你可以使用“-f”。
ln -sf /var/better orig
From man ln
来自
man ln
-f, --force remove existing destination files
-f, - force删除现有目标文件
你需要的只是cp:
cp -sf /var/better orig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.