linux copy symbolic link

linux copy symbolic link [closed]

up vote 19 down vote favorite

1

How do I copy a symbolic link from one directory to another?

ls -ls

file1.txt
file2.txt
files -> /mnt/iscsi-nfs-share/faulttracker-files

what I'm looking to do is copy files symbolic link into another directory?

cp files /var/copylinktohere/

the above results in cp: omitting directory `files'

linux shell command-line symlink cp

shareimprove this question

edited Dec 30 '13 at 0:44

Benjamin

10.9k1692169

asked Apr 26 '12 at 9:47

Robbo_UK

93562649

closed as off-topic by Benjamin, bmargulies, iandotkelly, Tim Dean, Michael Kohne Dec 30 '13 at 2:59

  • This question does not appear to be about programming within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
 
   

im only looking to copy the symlink not the actual contents of the directory – Robbo_UK Apr 26 '12 at 9:48

5 

Did you have a look in the manual pages? If not, is --no-dereference what you're looking for? – HonkyTonk Apr 26 '12 at 9:52

   

thanks for this gave plus one. I found all the options available a little confusing. – Robbo_UK Apr 26 '12 at 9:59

3 

Belongs to unix.stackexchange.com – Benjamin Dec 30 '13 at 0:43

   

@Benjamin: Fair comment — no mention of C. It is still on topic as it is about how to write shell programs (even if it is a one-liner). As such, it is fine on Stack Overflow. – Jonathan Leffler Dec 30 '13 at 14:11

add a comment

1 Answer

active oldest votes

up vote 33 down vote accepted

Use the -d option:

cp -d files /var/copylinktohere/

From man cp:

 -d     same as --no-dereference --preserve=link --no-dereference
          never follow symbolic links

shareimprove this answer

answered Apr 26 '12 at 9:51

dogbane

132k40230317

 
   

does this work if the symbolic links are not relative? ie copying into a destination directory higher or lower than the source directory. – Andrew Brown Mar 20 '14 at 6:57

add a comment

Not the answer you're looking for? Browse other questions tagged linux shell command-line symlink cp or ask your own question.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值