Find Exactly word in grep command


 
Thread Tools Search this Thread
# 1  
Error Find Exactly word in grep command

Hi all


How can i find Exactly line using grep.
my input file:
avg_configfile:
Recalculation Dates|4|
Recalculation|147|

I tryed like;
grep ^"Recalculation" avg_configfile

out put;
Recalculation Dates|4|
Recalculation|147|

But i want second line avg_configfile.i.e Recalculation|147| only.
please help me on this.
# 2  
If you want to match EXACTLY the second line do:

Code:
grep "^Recalculation\|147\|$" avg_configfile

# 3  
Rama,
if you want to find the exact word just put that word in the grep command.If the word is same it will give you multiple occurences.

eg.
if a string is like this

hi i am mosotronic.
mosotronic123 is a good boy.
mosotronic is studying unix.

some thing like that.

if you do a grep for robotroninc it will grep you all the 3 occuremces of the word.but if you want to find robotronic123 just give the exact word inside quotes it will do the things for you.

In youe question both the words are diff so just put the exact word as suggested by robotronic.
# 4  
Quote:
Originally Posted by robotronic
If you want to match EXACTLY the second line do:

Code:
grep "^Recalculation\|147\|$" avg_configfile

Or

Code:
grep -w 'Recalculation|147|' avg_configfile

# 5  
Quote:
Originally Posted by koti_rama
Hi all


How can i find Exactly line using grep.
my input file:
avg_configfile:
Recalculation Dates|4|
Recalculation|147|

I tryed like;
grep ^"Recalculation" avg_configfile

out put;
Recalculation Dates|4|
Recalculation|147|

But i want second line avg_configfile.i.e Recalculation|147| only.
please help me on this.
grep -w recalculation\|.*\| inputfile
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

2. Linux

How to search multiple word using grep command?

How to search multiple word using grep command for example i want to reserch ANJ001 AA Using ridiculous font, size, and color changes instead of normal space separated text and CODE tags obfuscates what you are trying to do and makes it difficult for volunteers who may want to help you solve... (1 Reply)
Discussion started by: na.dharma
1 Replies

3. UNIX for Dummies Questions & Answers

Find/grep Command

Kinldy help me to write the find command on following: There are different version of file 'abc.txt' located in many folders similar as below. /home/gupta/abc.txt /home/gupta/db/abc.txt /home/gupta/temp/abc.txt /home/gupta/db/test/abc.txt 1) I want to know... (4 Replies)
Discussion started by: ravigupta2u
4 Replies

4. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

5. Shell Programming and Scripting

Command to grep a word and print the whole line splitted into many

Hi, I need to search a word in the java file. Assume the line in the java file is, (the line was splitted into 3 lines) 1.operationContext.sendFeedback(2.FeedbackType.ERROR, null, "Input is empty.", "Input Details: pr 3.ovide Valid pair(s): "+pairType); When i grep for the word... (6 Replies)
Discussion started by: tulasiram
6 Replies

6. Shell Programming and Scripting

How to use grep & find command to find references to a particular file

Hi all , I'm new to unix I have a checked project , there exists a file called xxx.config . now my task is to find all the files in the checked out project which references to this xxx.config file. how do i use grep or find command . (2 Replies)
Discussion started by: Gangam
2 Replies

7. UNIX for Dummies Questions & Answers

Can grep command return word instead of complete line

Hi Is there any way GREP command can return word and not complete line. My file has following data: Hello Everyone I am NitinrajSrivastava Hi Friends Welcome VrajSrivastava I am using grep 'raj' which is returning me complete line.However I want only the word having keyword 'raj'. Required... (11 Replies)
Discussion started by: dashing201
11 Replies

8. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

9. Shell Programming and Scripting

help in find and grep command !

i have some 2000 file. i need to grep a particular word in all those files and list the filename that contains it? grep -l '0008345923LG' *.* the above command is not working? giving o/p as arg list too long PLZ anyone help me Thnaks in advance (1 Reply)
Discussion started by: ali560045
1 Replies

10. UNIX for Dummies Questions & Answers

Searching mutiple word - Tuning grep command

Hi all, I have a log file which is more than 1GB, i need to take count from the log file for two strings. i am using the below command but it take a long time to excetue, i need to tune this. Please help me cat /logs/gcbs/gcbsTrace.log | grep -i "ViewStatementBusinessLogic" | grep -c -i... (8 Replies)
Discussion started by: senthilkumar_ak
8 Replies

Featured Tech Videos