查找命令输出没有给出想要的结果

Sub*_*kur 0 command-line find

创建文件

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文件?

mos*_*svy 7

的:由于操作者的优先级的隐式(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)

打印所有文件。