cp a symlink to multiple directories

Today I wanted to copy a symlink to many different directories. So I tried the following:

for f in `find . -regex ''.*cp.*snippets''` ; do cp bbb.html $f/ ; done

Which returned:

cp: cannot stat `bbb.html': No such file or directory

bbb.html is a symlink and the default behavior of cp (I think) is to try and copy the actual file, which didn’t exist from the current directory. So just adding the -R made cp copy it as a symlink with the final command being:

for f in `find . -regex ''.*cp.*snippets''` ; do cp -R bbb.html $f/ ; done
  • del.icio.us
  • Reddit
  • Technorati
  • Twitter
  • Facebook
  • Google Bookmarks
  • HackerNews
  • PDF
  • RSS
This entry was posted in tips and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.