Problem to the command
Hi,
what to adjust below [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. |
Code:
find . -type f -exec grep 192.168 {} \; > log.txt |
Quote:
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 https://social.msdn.microsoft.com/Fo...HuaMin2020Chen Can you please calm down and be sincere, in all of the times? |
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 Code:
find . -type f -exec grep -ls 192.168 {} \; > files.txt Code:
sudo grep -ls pam_unix /var/log/* -R 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. Search is your friend. Have a great day! |
Quote:
|
Quote:
http://www.linuxquestions.org/questi...nd-4175552504/ http://www.linuxquestions.org/questi...le-4175555893/ Again, look back at your posting history. These: http://www.linuxquestions.org/questi...le-4175556409/ http://www.linuxquestions.org/questi...os-4175558002/ http://www.linuxquestions.org/questi...ql-4175544447/ http://www.linuxquestions.org/questi...le-4175542731/ http://www.linuxquestions.org/questi...le-4175543582/ http://www.linuxquestions.org/questi...le-4175543090/ ..are some good examples of things you could have easily looked up. |
Quote:
Code:
grep -irl "pattern" . |
Pan64,
I cannot find out the relevant by this grep -irl "192.168" . |
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)
|
Quote:
|
Quote:
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. Test it out. Learn from your experience. Code:
echo "192.168" >> $HOME/test.txt Code:
grep -irl "192.168" $HOME Code:
/home/jj/test.txt |
Hi,
I do not know it does keep waiting below https://dl.dropboxusercontent.com/u/40211031/tt392.png for long time |
Quote:
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. |
Hello.
Besides, it is more secure to use 'execdir' instead of 'exec' in find command. |
All times are GMT -5. The time now is 06:00 AM. |