Replace soft link with the original file

So you have a directory which contains soft aka symbolic links or symlinks. You want them gone, replaced with the actual files they are pointing to.

This one-liner will do the job:

  • for i in $(find . -maxdepth 1 -type l); do cp --remove-destination $(readlink $i) $i; done
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s