Deleting files in a text file (OSX)

ShareShare on FacebookTweet about this on TwitterPin on PinterestShare on Google+Share on Reddit

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

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

Caveats:
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 *