Possible Duplicate:
Why does Mac's $find not have the option -printf?
Not sure what is wrong with the following command, but can anyone spot the error:
find public_html -name '*.php' -printf '%h \n' | sort -u > dirlist.txt
Basically, I am attemtping to find out in my public_html directory names of all directories that have *.php extension. and then print out the directory in which that file is found. The output of this is piped to sort, duplicate entries are removed by the -u flag, and the result is stored in new file dirlist.txt
But what I am getting upon execution is :
find: -printf: unknown option
Not sure where I am getting this wrong
Thanks
Your version of find seems to have no -printf option.
I would do the same task like so:
find public_html -type f -name '*.php' | xargs -n1 dirname | sort -u > dirlist.txt
yes, your version does not seem to have -printf option - Mac variant doesnt i know - there may be others
your alternative is to pipe it to sed and sort, like so:
find public_html -name '*.php'|sed 's#\(.*\)/.*#\1#' |sort -u
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With