command tofind files by extension through a directory tree, and copy them all to the
Ok, I should know how to do this already, but I don't, and google didn't help me find exactly what I want, so I'm here to pick the brains of people smarter than I.
I want to search down through a directory tree and find files with a certain extension, then cp or mv them all to the same directory. For example. I want to find all the .txt documents in my home dir, and copy or move them all to my /home/me/doc dir. They could be in any of /home/me/text/words /home/me/text/sentences or /home/me/text/pdf. I'm sure there is a simple command for this, but "ls | grep .txt | cp" type stuff I've tried doesn't work. Thanks much for setting me straight. David |
mv -f /home/me/text/*/*.txt /home/me/doc
Something pretty much like the above ought to work! Sasha |
find can do what you want when used with the exec action.
Code:
man find Code:
info find Code:
find -iname '*.c' -exec grep -q SDL '{}' ';' -print |
All times are GMT -5. The time now is 09:14 PM. |