I have multiple .mkv files in eng.md which listed by codes
$ grep -i 'mkv' eng.md
./Volumes/Transcend/Downloads/The.Adventure.of.English.Ep4.mkv
./Volumes/Transcend/Downloads/The.Adventure.of.English.Ep5.mkv
./Volumes/Transcend/Downloads/The.Adventure.of.English.Ep6.mkv
./Volumes/Transcend/Downloads/The.Adventure.of.English.Ep7.mkv
./Volumes/Transcend/Downloads/._The.Adventure.of.English.Ep4.mkv
./Volumes/Transcend/Downloads/The.Adventure.of.English.Ep8.mkv
./Volumes/Transcend/Downloads/._The.Adventure.of.English.Ep8.mkv
./Volumes/Transcend/Downloads/._The.Adventure.of.English.Ep5.mkv
./Volumes/Transcend/Downloads/._The.Adventure.of.English.Ep6.mkv
I decide to remove mkv files with pipeline methods and try
$ rm < grep -i 'mkv' eng.md
-bash: grep: No such file or directory
Try alternatively
$ grep -i 'mkv' eng.md | rm
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
grep: eng.md: No such file or directory
How to resolve such a problem?
Like this, (unless it's some huge list of files that exceeds the command line maximum length):
rm $(grep -i mkv eng.md)
Since neither of the comments really gave a solution which works for every situation, I propose here an approach slightly modified from what shirish suggested in his comment:
grep '[.]mkv$' eng.md | xargs rm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With