[转]linux ls cp等命令的-H/-L参数

[转]linux ls cp等命令的-H/-L参数

-H Symbolic links on the command line are followed. This option is assumed if none of the -F, -d, or -l options are specified.

-L Follow all symbolic links to final target and list the file or directory the link references rather than the link itself. This option cancels the -P option.

——摘自ls的manual

参数-L比较清楚,就是对所有的symlinks都dereference
但如果单独使用-H,结果并没有任何变化

后来看到superuser上一篇回答,终于弄懂了-H的作用:
linux -cp -H vs cp -L(What is a command line symbolic link)


其中有句话,看到后恍然大悟:

Without the -R switch, the behavior of cp -H and cp -L is identical.

感觉manual里没讲清楚,-H其实应该搭配着-R用的,这就是-H和-L的不同:

With the -R switch, cp -H only dereferences symbolic links that occur in the cp command itself, while -L also dereferences symbolic links inside the recursively copied directories.

比如,在 cp -HR source/ dest/ 中,如果 source/ 是symlink,那cp就会把symlink指向的原文件copy到 dest/,但是,对于 source/ 中包含的symlinks,仅仅copy 这些symlinks本身

However, if cp encounters any symlinks in source’s subdirectories, it will create symlinks in the destination folder.

cp -HL source/ dest/ 则不仅dereference command line中的source(symlink),还会对递归中遇到的所有symlinks进行dereference

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值