Egrep issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Egrep issue
# 1  
Old 06-04-2013
Egrep issue

HI

How can i grep!!!

Code:
**NO**|**Yes**

I have below command but it will not work

Code:
egrep -i '**NO**|**Yes**' *.log

# 2  
Old 06-04-2013
What have you tried?

Please show some work, including your initial data that you are trying to process and the desired output.
# 3  
Old 06-04-2013
My Input file lilke below :
Code:
             01       1                  01           00       -106.4     -108.5     2.1     **NO**    
             02       1                  01           01       -106.2     -106.5     0.3     **NO**    
             03       1                  01           02       -106.3     -106.4     0.1     **Yes**

# 4  
Old 06-04-2013
Not sure of your input, but

Take a look at the following. You will need to escape for the * as it is a wildcard. Note that the last example did not return anything.

Code:
$ echo **YES **No
**YES **No

$ echo **YES **No | grep "*"
**YES **No

$ echo **YES **No | grep "\*"
**YES **No

$ echo **YES **No | grep "\*\*YES"
**YES **No

$ echo **YES **No | grep "\*\*YET"

# 5  
Old 06-04-2013
Why not just grep for YES,NO without the *?
grep -E "YES|NO"
Gives all lines with YES, or NO
# 6  
Old 06-04-2013
Note for Joeyg's example: shells will try to glob (find matching files names for) the ** characters.

In bash (as an example) you can turn off globbing with
Code:
set -o noglob

# 7  
Old 06-04-2013
The asterisks would need to be escaped from shell, but also from grep:
Code:
grep -Ei "\*\*(yes|no)\*\*" file

Unless the -F option is used. Try:
Code:
grep -Fie '**yes**' -e '**no**' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Issue when using egrep to extract strings (too many strings)

Dear all, I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error: ... (3 Replies)
Discussion started by: forevertl
3 Replies

2. Shell Programming and Scripting

Using egrep.

I have a text file which has the content starting with "....." Not able to filter out lines staring with "....." Is there anything wrong with grep stagement ?? .....processing table 2 of 2 .....migration process started at 2012-10-04 05:00:28 .....estimated # of rows 169,830... (2 Replies)
Discussion started by: Nagaraja Akkiva
2 Replies

3. Shell Programming and Scripting

egrep help

hi, i'm using egrep -i to search thru some text files for keywords (also stored in a file). egrep does wildcard search aka %keyword% as long as the keyword is found, it will be spool to a file meaning if keyword is 'xyz' 123 aabgdggjxyzslgj 124 xyzgjksgjd returns 123... (8 Replies)
Discussion started by: bing
8 Replies

4. Shell Programming and Scripting

RegExp and egrep issue

I would like to to catch the ip at the following line with egrep and regexp: ip = 192.9.110.20 and I built the following regexp to do it: (?<=ip\s=\s)\S+ when I check it with regexp simulator, it works but when I use it in the following egrep command it doesn't work - egrep -e... (2 Replies)
Discussion started by: datrigger
2 Replies

5. UNIX for Dummies Questions & Answers

search ")" with egrep - egrep: syntax error

Hi Guys, we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" . Now there is some data which contains characters like "abc)" and the same is used like below : "egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt" now while... (7 Replies)
Discussion started by: sagarjani
7 Replies

6. Shell Programming and Scripting

help on egrep

Hi there, How many multiple values can be in egrep for seraching? i am giving more values but i am getting the error like Unknown error. My input in extended to 2nd line. my command is like below. egrep -i -h... (2 Replies)
Discussion started by: arund_01
2 Replies

7. Shell Programming and Scripting

egrep help

Hi there, Im having some issues using egrep, I have a text file containing server logs: the user imputs 2 arguments, which are error checked and made into $searchMonth $searchYear respectivley. I then do the grep command: egrep /$searchMonth/ $file | egrep /$searchYear: | wc -l ... (1 Reply)
Discussion started by: Darklight
1 Replies

8. UNIX for Dummies Questions & Answers

Egrep cheat sheet anywhere? Looking for meaning of egrep -c

Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means? thanks, Linda (2 Replies)
Discussion started by: leelm
2 Replies

9. UNIX for Dummies Questions & Answers

help with egrep

I have a file called alert.log containing the following: WARNING: received KRVX_OPER_CANNOT_SUPPORT knlldmm: gdbnm=CROOP knlldmm: objn=23793 knlldmm: objv=1 knlldmm: scn=5189816456 knllgobjinfo: MISSING Streams multi-version data dictionary!!! knlldmm: gdbnm=FDROP knlldmm: objn=49385... (9 Replies)
Discussion started by: akDBA
9 Replies

10. Shell Programming and Scripting

egrep help

How can i make something like if (echo "$arg2" | egrep -s '^+\.+km/h+$|^+km/h+$'); then not to output the value of $arg2 on the screen, evertime i get match it outputs the value of the variable on the screen which i don't need to do. I know for grep its -q option but it doesn't work for egrep.... (2 Replies)
Discussion started by: Vozx
2 Replies
Login or Register to Ask a Question