how to search files apart from GREP??
how can i search any file on RHEL5 without using Grep command as it takes the process in pipeline and it takes hell lot of time to search a file.
do suggest any other searching command pls. thank you all. |
Hi,
Although you can use sed or awk to search file(s), grep was specifically written to do this. I do assume that grep will be more efficient then sed/awk (or other standard tools). Using sed: sed -n '/<string>/p' <infile> Using awk: awk '/<string>/ { print }' <infile> Anyway, hope this helps. |
It seems to me that the time to search a file will be dominated by the amount of disk access required---so the actual code being used might not make that much difference.
Quick experiment: Search 730Kbyte file for a single word: grep: 0.07 sec sed: 0.08 sec BTW, these commands don't require piping, e.g.: grep keyword filename sed -n '/keyword/p' filename |
Yes....I too completely agree that "grep" is much more efficient than sed or awk. sed/awk are mainly designed for pattern matching.
Also, from your question I am not much clear. If you want to search a particular word/string from a file then use awk like this awk'/pattern/{print }'<filename> If you are trying to find a whole file frm the file system then use the find command as find <path> -name <filename> Cheers, sir_com |
Quote:
grep from? |
I'm interpretting this question as "I want to find a particular file on my system" instead of "I want to find a particular string in my file."
If I'm right, then you should take a look at the find command. I would do something like: Code:
find /my/directory -iname 'My_file*' |
If you're looking for a file on your system, I recommend locate or slocate.
|
All times are GMT -5. The time now is 10:35 PM. |