1

I want to list every file that ends with "conf", and output the results to a given file (with the command find -exec).

I tried this:

find -name *conf -exec /home/ubuntu/myfile

Is this wrong?

10

-exec is used for running a program, not printing the output. Use -print to print the output, and shell redirection (>) to store that output in a file:

find -name \*conf -print > /home/ubuntu/myfile

Note that I escaped the * with a backslash; this is because the shell will attempt to match the wildcard before starting find, so if you happened to have a file that ended in conf in the current directory, the shell would replace *conf with that filename (or names) before starting find.

5
find /path -type f -iname "*.conf" > /home/ubuntu/myfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.