我在.mkv
中有多个eng.md
文件,按代码列出
$ 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
我决定用管道方法删除mkv文件并尝试
$ rm < grep -i 'mkv' eng.md
-bash: grep: No such file or directory
交替尝试
$ grep -i 'mkv' eng.md | rm
usage: rm [-f | -i] [-dPRrvW] file ...
unlink file
grep: eng.md: No such file or directory
如何解决这样的问题?
最佳答案
像这样,(除非是一大堆文件exceeds the command line maximum length):
rm $(grep -i mkv eng.md)