如何应对Linux提示符(基于关键词的提示)
rm -i test_file*
rm: remove regular empty file 'test_file'?
rm: remove regular file 'test_file1'?
我想回答“是”,在关键词空存在的提示,并没有回答其他。如何应对Linux提示符(基于关键词的提示)
我试过(它不工作)
yes | grep "empty" | rm -i test_file*
当您打字:
yes | grep "empty" | rm -i test_file*
你传入yes
结果grep
具有不知道它应该通过yes
结果rm
您可以在单个文件上以这种方式(在bash上)执行此操作:
file test_file |grep empty && yes | rm -i test_file
在多个文件(仍然庆典):
for file in *.dat; do file $file | grep empty && yes | rm -v $file ; done
它涉及两个删除单个文件的调用! – Ravichandra
那么,OP中的'find'-based解决方案仍在工作;) – peyo
Yah,但我在寻找回复提示逻辑:) – Ravichandra
您正在使用哪个Shell'bash'?从命令输出中搜索不是有效的方法,你可以使用'find'吗?如果你的目的是删除所有的零字节文件? – Inian
@Inian是对的,'找到。 -name“test_file *”-type f -empty -delete'窍门 – peyo