Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There is a good utility named ' man ' which will help you
better than me ;)
man find :
Code:
-exec command ;
Execute command; true if 0 status is returned. All
following arguments to find are taken to be argu_
ments to the command until an argument consisting
of `;' is encountered. The string `{}' is replaced
by the current file name being processed everywhere
it occurs in the arguments to the command, not just
in arguments where it is alone, as in some versions
of find. Both of these constructions might need to
be escaped (with a `\\') or quoted to protect them
from expansion by the shell.
should do what you want, but if you're gonna ask questions about every single linux command you're going to get annoying very quickly. I suggest you do what an earlier poster recommended and read the man page for anything you're not sure about. The questions you're asking are BASIC syntax questions for commands that can be answered just by reading the manual page for that command.
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662
Original Poster
Rep:
Komakino
It worked very well. I take my hat off for the help. This is a very simple command to find a text in your documents; it just has a few words. If you compare it with the ' find ' command, this is a very short one. I can always write it without looking at a written paper on those commands.
I use to look at some papers before writing commands like ' grep ' , 'egrep' , ' fgrep ' and ' find ' . I have written down all the important commands. I always make mistakes if I wrote a command without looking at a paper.
I would like to know the meanings of the switches.
In this case -r is recursive - it means that if it encounters a directory it moves into that directory and continues looking through files (and so on)
-H means it prints the name of the file in which it found the matching text, and the line it appears on.
* is the wildcard - it matches everything and in this case it's in the position where you would put the name of the file you want to search in. For example, if I just wanted to search in a file called sample1234.txt to see if it contained the word Schroeder, I could do:
Code:
grep Schroeder -H sample1234.txt
(and I wouldn't need the -r because I'm not going to encounter any directories)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.