Unix egrep


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Unix egrep
# 1  
Old 05-19-2012
Question Unix egrep

I can not find error why my script does not work .


Code:
egrep -n "is" $egrepline

where
Code:
egrepline = "filename1 ...filenameN"

supposed result:
Code:
filename1:linenumber: matched line.
.
filenameN:linenumber: matched line

If more than 2 files as
Code:
egrepline = "filename1 filename2"

, I get correct format

If only one file as
Code:
egrepline = "filename1"

,

my result is wrong format as:
Code:
filename1
:linenumber: matched line.

I try
1. egrep -n "is" $egrepline
2. egrep -n "is" "$egrepline"
3. egrep -n "is" {$egrepline}

I can not get correct format

Is there any missing word in my command? Please help.

Thank you
# 2  
Old 05-19-2012
The easiest solution in my opinion is to add dummy file at the end:
Code:
egrepline="filename1"
egrepline="$egrepline /dev/null"
egrep -n "is" $egrepline

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 05-20-2012
Bug

Thank you . Its work!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Egrep

Hi I am trying to run CMD that combining EGREP and PERL in multiple files cat *07:00.22-12-13.txt | egrep" NAME| perl -ne 'print if /^sid9/ .. /^!/' " I need the see the NAME and the text from sid9 to ! how can I use the EGERP in parallel to the PERL ? This is one file Qqq... (2 Replies)
Discussion started by: sharong
2 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

Hi, I am wondering if it's possible to link multiple patterns with egrep. Here here is what I am doing : grep -v ";;" | grep -v ARC_TIME | grep -v \* | grep -v STAS0 Can I do all of this by invoking egrep just once ? Thanks (4 Replies)
Discussion started by: Aswex
4 Replies

4. Shell Programming and Scripting

egrep

i am new to bash or scripting period and had a question about how I could use the egrep command (or if there should be another command to use) to accomplish the following goal. Need to look through the ndm files labeled as S20090709.999 and if I cannot find a specific date then search the archived... (5 Replies)
Discussion started by: freddie999
5 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

ls and egrep together

Hello, Why is this not returning files containing the string in the var $files? files=`ls /dir1/dir_level2/dir_level3 | egrep "catch \["` files=`ls /dir1/dir_level2/dir_level3` this by itself returns a list of files which I thought could be sent through grep or egrep to look for matches. ... (5 Replies)
Discussion started by: gio001
5 Replies

7. UNIX for Dummies Questions & Answers

egrep

HI, I want to grep the contents of fileb from filea. filbeb 5x4xxx371x31a43 4x40x037103a049 3x4x003710a0659 4x4x0x371a50912 filbea 5x4xxx371x31a43 3266000225 4x4003266000277 3266000277 4x400326x000499 3266000499 4x4003266000676 3266000676 4x4x0x371a50912 3266000777... (4 Replies)
Discussion started by: krao
4 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. UNIX for Dummies Questions & Answers

Egrep Help

I'm writing a small script thats purpose is to validate a single command line argument to make sure it is an integer. Also acceptable are a leading "+" or "-", but no more than one. Example: "5" "-2" "+4" are all valid If its invalid I simply print out a message saying so, otherwise I... (2 Replies)
Discussion started by: FuzzyNips
2 Replies
Login or Register to Ask a Question