How to remove a symbolic link and the file it targets

ls -al NameOfFile | awk ‘{print “rm “$9”; rm “$11}’

The above command will show you what is to be removed

ls -al NameOfFile | awk ‘{print “rm “$9”; rm “$11}’ | sh -x

Piping the output into sh -x will execute the commands and remove both the source and the target. Be certian you want to do this!

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *