ske*_*mal -1 command-line files find ls
我想列出当前工作目录(home)中所有不带扩展名(.txt)的 ASCII 文件。我从终端中的命令开始ls
,但我不知道应该在选项中放入什么,因为我想列出没有扩展名而只有名称的文件。我该怎么做?
运行以下命令:
find . -maxdepth 1 -type f ! -name "*.*" -exec grep -lvIP '[^[:ascii:]]' {} +
Run Code Online (Sandbox Code Playgroud)
find
是一个更强大的ls
。. -maxdepth 1
表示仅当前目录-type f
表示仅文件! -name "*.*"
表示排除带有扩展名的文件-exec grep
...表示通过命令{} +
过滤文件列表grep
-lvIP '[^[:ascii:]]'
表示仅显示-l
不包含-v
任何非 ( ^
)-ascii 字符且也不包含二进制数据 ( -I
) 的文件。在模式中-P
使用字符类需要Perl 语法。[:ascii:]