创建文件
touch a1.txt a2.txt a3.txt
touch s1.mp3 s2.mp3 s3.mp3
Run Code Online (Sandbox Code Playgroud)
然后我做
find . -name "*.txt" -or -type f -print
Run Code Online (Sandbox Code Playgroud)
而且它只显示s1.mp3
s2.mp3
s3.mp3
. 为什么不显示.txt
文件?
的:由于操作者的优先级的隐式(AND -a
)之间-type f
并且-print
具有比所述OR(更高的优先级-o
;)你的命令类似于
find . \( -name "*.txt" \) -or \( -type f -print \)
Run Code Online (Sandbox Code Playgroud)
虽然你可能想要
find . \( -name "*.txt" -or -type f \) -print
Run Code Online (Sandbox Code Playgroud)
打印所有文件。