Deleting files in a text file (OSX)

Someone had a list of absolute paths of files they needed to delete. I sent them this tiny script to help them out:

sed ‘s/\ /\\ /g’ filelist.txt | xargs rm

Take filelist.txt, replace all the spaces with backslash space and pipe to xargs to run rm on each file.

This does not escape any other characters that might cause problems (like single quotes, etc.)

This entry was posted in technology and tagged , , , . Bookmark the permalink.

Leave a Reply

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