我正在写这个oneliner,它给我一个错误,如语法错误,意外的文件结束。我希望它是一个oneliner并删除文件夹“uso”中找到的.c扩展名的所有文件。谢谢!
#! /bin/bash
for file in $(find uso | grep "[.][c]$"); do rm -rf $file done
答案 0 :(得分:1)
在末尾添加一个分号。
for file in $(find uso | grep "[.][c]$"); do rm -rf $file; done
顺便说一下,更好的方法是:
find uso -name '*.c' -delete # GNU find
find uso -name '*.c' -exec rm -f {} \; # POSIX find
这些将安全地处理包含空格的目录和文件名。
答案 1 :(得分:0)
你需要在完成之前添加缺少的分号,
for $ file(find uso | grep“[。] [c] $”);做rm -rf $文件;完成
就像上面一行。