about grep
I would like to grep the word "ABC" from a directory , if I use "grep ABC *" , it will output all word that contains ABC ( eg. ABCD , ABCDE.... ) , can advise if I only want to find the file have the word ABC , what can I do ? thx
|
It's difficult to understand what you are asking for.
If you are looking to find all files in the current directory, or subdirectories thereof, which contain the pattern ABC anywhere in their name, then you want: Code:
find . -name '*ABC*' Code:
find . -name 'ABC*' --jrtayloriv |
grep " ABC " *
? |
Code:
ls *ABC* |
\b for word boundary:
grep '\bABC\b' * |
Quote:
--jrtayloriv |
if your ABC is having spaces around then try this...
grep " ABC " input > output or grep "ABC " input > output or grep -E " ABC |ABC " input > output |
it seems not work,
my requirement is not difficult in my directory , there are some files contains ABC , ABCD , ABCDE , what I want is to use grep to find the file that contains ABC , I use grep "ABC" * , it will show all the files ( includes ABCD , ABCDE ) , can advise what can i do ? thx |
Quote:
Quote:
Perhaps what you are looking for is: Code:
ls | grep -w ABC |
Another way is:
Code:
find . -name ABC |
Are you looking for files that contain ABC or filenames that contain ABC?
|
All times are GMT -5. The time now is 08:08 PM. |