Assuming that the list of files is in the file 1.txt
, then do:
xargs rm -r <1.txt
The -r
option causes recursion into any directories named in 1.txt
.
If any files are read-only, use the -f
option to force the deletion:
xargs rm -rf <1.txt
Be cautious with input to any tool that does programmatic deletions. Make certain that the files named in the input file are really to be deleted. Be especially careful about seemingly simple typos. For example, if you enter a space between a file and its suffix, it will appear to be two separate file names:
file .txt
is actually two separate files: file
and .txt
.
This may not seem so dangerous, but if the typo is something like this:
myoldfiles *
Then instead of deleting all files that begin with myoldfiles
, you'll end up deleting myoldfiles
and all non-dot-files and directories in the current directory. Probably not what you wanted.