Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
[root@hpi5 /]# find . -type f -exec grep -il "192.168" {} > log.txt
find: missing argument to `-exec'
[root@hpi5 /]#
as I want to search all files (including sub-folders) having one specific string inside.
Read the man page on the find command and you'll see. Pay attention to the recursive flag. Read the "Question Guidelines" link in my posting signature.
You have been here for FOUR YEARS, and have close to 500 posts. You should know by now to do basic research on your own, and show some effort of your own. Asking others to look things up for you and spoon feed you repeatedly isn't nice.
TBOne,
Forum is to share knowledge and experience (as human being cannot know everything and this is why many kind of Forums do exist on the planet!), and I did contribute in the same way in some other places, like
Huamin:
There are several variations of grep'ing you should now about...
Let's say you're only interested in find the file names where 192.168 exists, you
could then use
Please bookmark this excellent site for future reference:
It's where I learned to "cut my teeth" on most things command-line
Understand our position also, we get 1000s of visitors every day asking the same basic questions.
90% of their answers are found in the man pages and are considered basic.
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
Quote:
Originally Posted by Huamin
TBOne,
Forum is to share knowledge and experience (as human being cannot know everything and this is why many kind of Forums do exist on the planet!), and I did contribute in the same way in some other places, like
Can you please calm down and be sincere, in all of the times?
Tend to agree with you on this one it's easy enough to miss somthing like a trailing semi-colon and the command was mostly OK so I think a bit of an over reaction on TBOne' part, but then again we all have off days where everything anyone does just gets our back up.
TBOne,
Forum is to share knowledge and experience (as human being cannot know everything and this is why many kind of Forums do exist on the planet!), and I did contribute in the same way in some other places, like
First, I was (and am) calm. Secondly, what you do anywhere else, doesn't matter in relation to what you do HERE. Third, and most importantly, my comment is valid. After FOUR YEARS and close to 500 posts, why can you not read the man pages yourself? There are over TWO MILLION hits in Google for "how to find files in all subdirectories in linux". What prevented you from looking this up? Or better, reading some of your OTHER threads, asking how to find files: http://www.linuxquestions.org/questi...nd-4175552504/ http://www.linuxquestions.org/questi...le-4175555893/
I do not really understand you again. This should give [almost] the same result as your first attempt (with find and grep). If you need another kind of output see the man page of grep and check the flags -n -l -c (and any other one you like)
I do not really understand you again. This should give [almost] the same result as your first attempt (with find and grep). If you need another kind of output see the man page of grep and check the flags -n -l -c (and any other one you like)
I wish you luck in getting the OP to read man pages.
Then it doesn't exist, or you did it incorrectly.
You realize that "." is the current directory and grep -irl will search from the current directory down/under?
And doing this from the / directory becomes most inefficient.
You forgot the dot. The way you run grep it reads from standard input, not from the current directory.
As pan64 said, read the man page. It's not very useful to blindly follow what other people tell you; you also need to understand what those commands do.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.