use*_*069 5 macos bash shell pipe
不确定以下命令有什么问题,但任何人都可以发现错误:
find public_html -name '*.php' -printf '%h \n' | sort -u > dirlist.txt
Run Code Online (Sandbox Code Playgroud)
基本上,我正在寻找在我的public_html目录中找到所有具有*.php扩展名的目录的名称.然后打印出找到该文件的目录.输出通过管道进行排序,重复的条目被-u标志删除,结果存储在新文件dirlist.txt中
但我执行的是:
find: -printf: unknown option
Run Code Online (Sandbox Code Playgroud)
不确定我在哪里弄错了
谢谢
您的find版本似乎没有-printf选项.
我会像这样做同样的事情:
find public_html -type f -name '*.php' | xargs -n1 dirname | sort -u > dirlist.txt
Run Code Online (Sandbox Code Playgroud)