unable to use grep use grep command in Centos 7
unable to use grep use grep command in Centos 7
Hi All,
currently i am using centos 7 , while using grep unable to get any result same issue with piping .
Please advice
currently i am using centos 7 , while using grep unable to get any result same issue with piping .
Please advice
Re: unable to use grep use grep command in Centos 7
More info please, e.g. what are your commands?
Re: unable to use grep use grep command in Centos 7
Be specific, what did you run, what did you expect to find, show the line from the target file containing the string you were looking for as well as the exact command you ran that did not work.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: unable to use grep use grep command in Centos 7
Hi
i using a simple searching and piping comnd : find . -type f | grep (character) .
But its showing no result no error message as well , for reference added the screen shot
i using a simple searching and piping comnd : find . -type f | grep (character) .
But its showing no result no error message as well , for reference added the screen shot
- Attachments
-
- grep not working.PNG (46.04 KiB) Viewed 11095 times
Re: unable to use grep use grep command in Centos 7
Your find command will list all files, not the content of them.
You could look at the fgrep command.
You could look at the fgrep command.
Re: unable to use grep use grep command in Centos 7
Please do not use screen shots, cut and paste into a code (</>) block. Otherwise anyone trying to help you has to copy type which is liable to put people off.
Now to your problem. If you do a plain:
You can see that the output of the find command is a list of file names, that is three strings Now think about the pipeline, it is passing this output to the input of the grep, essentially: I would hope it is clear that the substring "we" occurs nowhere in the string "./copy2.txt".
Try: Note the '{}' which tells find to inset the file name at that point, the execute the command. Do not forget the \; at the end or find will not know where the command ends. Have a read of the man page, it's all explained there.
Now to your problem. If you do a plain:
Code: Select all
find . -type f
./copy2.txt
./copy3.txt
./test1.txt
Code: Select all
echo "./copy2.txt" | grep we
Try:
Code: Select all
$ find . -type f -exec grep we '{}' \;
We should be do that , we are going.
Re: unable to use grep use grep command in Centos 7
Thanks for the help , i got it perfectly , and i am very sorry for the attachment .
Re: unable to use grep use grep command in Centos 7
Grep can recurse directory. No find is needed:
Code: Select all
grep -r we .
Re: unable to use grep use grep command in Centos 7
Neat. It only goes to show that us "old hands" ought to re-read the simple stuff from time to time - sometimes "that's the way I've done it for 20 years" is not always the most efficient! More seriously, that is great for simple searches, but remember that find has powerful selection mechanisms for more advanced searches.
Re: unable to use grep use grep command in Centos 7
The "File and Directory Selection" of man grep has some options, but yes, far from what find can.
There must be a way to find out, when such features have been injected into the code. Open source and all.
There must be a way to find out, when such features have been injected into the code. Open source and all.