Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am trying to run a find command on a directory and then pipe the output to either awk or into a loop for further processing. My find command works fine and outputs line of results, however, when I try to pipe the output to another command or loop, nothing happens, it just freezes. The command I am currently trying is:
find /media/backups/rsnapshots/ -name "CTG\.fp5" | while read i; do ls -l $i; done
I cannot understand what is stopping this from working as the output from the find on its own is simply lines of output, I have done plenty of googling and cannot `find` the answer. Maybe I'm just being a bit dim. Any help would be greatly appreciated.
Arfa that works great, thanks. What does the " '{}' \ " bit do?
And I am still confused about why my find command won't pipe to a loop or awk.
Hi Steven,
The '{}' puts the output of the find command in its place. If you do a "man find" you will see many options for the find command. There are heaps of great things you can do with the find command.
When I run your command on my system (Fedora 11 - find (GNU findutils)4.4.0)I get the following "error" :-
$ find . -name "song-name\.ogg"
find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name `song-name\.ogg'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ `song-name\.ogg''.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.