打印文件名并对查找的每个结果执行命令

Moh*_*sen 2 find

我正在尝试将两个命令(echohaml --check)应用于我的find.

haml --check `find . -name "*.haml"`
# return Syntax error on line 2: Illegal nesting: nesting within plain text is illegal.
# but I don't know which file

echo `find . -name "*.haml"`
# returns list of files (space separated) 
Run Code Online (Sandbox Code Playgroud)

理想情况下,我想打印文件名,然后haml --checkstdout.

rus*_*ush 8

还有一种没有 xargs 的方法:

find . -name "*.haml" -ls -exec haml --check {} \;
Run Code Online (Sandbox Code Playgroud)

仅打印带路径的文件名:

find . -name "*.haml" -print -exec haml --check {} \;
Run Code Online (Sandbox Code Playgroud)