rm -i test_file*
rm: remove regular empty file 'test_file'?
rm: remove regular file 'test_file1'?
我想在提示中出现的关键字empty中回答“yes”,在not中回答其他。
我试过了(没用)
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
在多个文件上(仍然是 bash):
for file in *.dat; do file $file | grep empty && yes | rm -v $file ; done
关于linux - 如何回复linux提示(根据提示中的关键字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45710595/