This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

You can see that the symlink point to the file in the same folder and doesn't use full-path but relies on relative path to link.

Now, I need a copy command that would copy all files named copy* in the sourceFolder to a destinationFolder. When I copy file copyA, it should copy the source of symlink i.e. fileA but keep the name copyA. The copy command should also work for copying file copyB.

Can this be done?

I tried these commands but it doesn't work, mostly because my reference is relative:

Can you correct your example? Sometimes you include sourceFolder, sometimes not. And also show what result you want? cp path1/* path2/ results in symlinks in path1 being copied to regular files in path2, for me.
– Joe PJun 15 '17 at 21:57

1

Using 4 spaces at the beginning of the lines is easier for blocks of coding than using lots of ` characters.
– Joe PJun 15 '17 at 21:58

This seems an odd thing to want to do. I would expect a requirement that a copy creates a broken link, which is then resolved when the target is copied. If you want this sort of behaviour, use hard links.
– AFHJun 15 '17 at 21:59