using egrep to get result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using egrep to get result
# 1  
Old 08-30-2008
using egrep to get result

Hi all,

Can egrep using AND OR ?, like egrep -i "title.$1" AND "category.$2" ./home....

I want to give two search criteria, the files where egrep is seaching in for example
looks like below rows.
title this is an test
category space

(command line input)
$1 script.sh this space

thanks
# 2  
Old 08-31-2008
With egrep:

search for $var1 OR $var2:

Code:
egrep "[$var1]|[$var2]" file

search for $var1 AND $var2:

Code:
egrep "$var1.*$var2|$var2.*$var1" file

Regards
# 3  
Old 08-31-2008
Thank you, that's exact what i need.
# 4  
Old 08-31-2008
Actually the examples are wrong. But this is a duplicate of another thread; see https://www.unix.com/shell-programmin...-new-post.html
# 5  
Old 08-31-2008
Hi Era,
thank you very much, this should be the solution? var1.*var2|var2.*var1, should this create the AND?
# 6  
Old 08-31-2008
Yes, that checks for var1 and var2 on one and the same line, in any order.
# 7  
Old 08-31-2008
thanks Era, just what i was looking for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

2. 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

3. 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

4. Shell Programming and Scripting

how to make menu of result from egrep

hi, im just starting with scripting , i have de following situation im doing a search in a data folder with egrep egrep -i "title.regu." `find . -name "*.dat"` the result is : ./20080816212245/index.dat:title Regular Expressions ./20080811212216/index.dat:title ... (5 Replies)
Discussion started by: tvrman
5 Replies

5. Shell Programming and Scripting

egrep/grep result of more files

hi , I'm new at unix bash scripting, im playing a little bit with egrep/grep. I have serveral files and i do a search on those files, like "aki", the result is many rows outcoming and serveral of them are dubble because aki wil come more than ones in a file, how can i get a result that it... (3 Replies)
Discussion started by: tvrman
3 Replies

6. 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

7. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 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. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

10. UNIX for Dummies Questions & Answers

egrep counting every 2 lines of result as 1

Hi, Can someone help me count this line: Say I have a file (file1.txt) that contains below: 11/16 13:08:19.5436 18096 --- Generating a <reading> event 11/16 13:08:19.7784 18096 ---- Sending a <writing> event 11/16 13:08:37.4516 18096 --- Generating a <reading> event 11/16... (1 Reply)
Discussion started by: Orbix
1 Replies
Login or Register to Ask a Question