I have a text file that has a list of paths to various files. Is there a command I can use that will iterate through each line and delete the file at the stated path?
Ubuntu – How to delete files listed in a text file
command linefiles
command linefiles
I have a text file that has a list of paths to various files. Is there a command I can use that will iterate through each line and delete the file at the stated path?
Best Answer
Use
xargs
:But that will not work if the file names/paths contain characters that should be escaped.
If your filenames don't have newlines, you can do:
Alternatively, you can create the following script:
Save it as
/usr/local/bin/delete-from
, grant it execution permission:Then run it with: