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?

link|improve this question
feedback

2 Answers

-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.

link|improve this answer
feedback
find /path -type f -iname "*.conf" > /home/ubuntu/myfile
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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