Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

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.

share|improve this answer
add comment
find /path -type f -iname "*.conf" > /home/ubuntu/myfile
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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