Can I combine below mentioned grep commands using OR (when searching strings having spaces)


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Can I combine below mentioned grep commands using OR (when searching strings having spaces)
# 1  
Old 12-26-2016
Can I combine below mentioned grep commands using OR (when searching strings having spaces)

Code:
Command 1: 
$script | grep 'Write to  ECC( SSID=MARGIN)'
Command 2: 
 $script | grep 'is not greater than existing logical processing'

The above commands run my script and search the mentioned strings but I do not want to run my script twice. It is increasing run time.

Can someone tell me some other way of combining these two commands.

The below won't work-

$script | grep 'Write to ECC( SSID=MARGIN)|is not greater than existing logical processing'
# 2  
Old 12-26-2016
Hi,

you are missing \ for basic grep to use or.

Code:
$script | grep 'Write to  ECC( SSID=MARGIN)\|is not greater than existing logical processing'

# 3  
Old 12-26-2016
Hello Tanu,

Could you please try to use grep's -E option by joining both searches with | only and let me know how it goes then.

Thanks,
R. Singh
# 4  
Old 12-26-2016
Many if not all grep take newline separated search patterns
Code:
$script | grep 'Write to  ECC( SSID=MARGIN)
is not greater than existing logical processing'

fgrep (plain string search) might be more appropriate than grep (RE pattern search).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine 2 Commands

Hello, I have the following code. I wonder if it can be combined into 1 command. y=`ls -1| tail -n 1` m=${y%.abc} Thank you. (3 Replies)
Discussion started by: april
3 Replies

2. Shell Programming and Scripting

Grep for all ip addresses mentioned in all files in a Directory

I wish to traverse all files and folders under a given directory say "/tmp/configuration" and for all ip address mentioned therein. I tried find ./ -type f | xargs grep "*.*.*.*" but it does not populated the correct results. Can you please suggest. (1 Reply)
Discussion started by: mohtashims
1 Replies

3. Shell Programming and Scripting

Grep for string, but within mentioned bounds

Hi, I've been trying to filter a file which has several repetitions of lines which looks as follows: ('hello My name is jamie blabla xyz>>) Each line has different values in them. I want grep or awk or sed to treat everything within the (' and >>) as one line and then filter for a... (2 Replies)
Discussion started by: jamie_123
2 Replies

4. Shell Programming and Scripting

How to combine two variable strings?

Hi, I have two variables pscmd="ps -exf | grep " pid=15560 When I say var=$( $pscmd $pid ) echo $var it shows output of all processes on the OS rather than just 15560. So, i guess it only executes "ps -exf | grep " rather than "ps -exf | grep 15560" Can you... (2 Replies)
Discussion started by: mohtashims
2 Replies

5. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

6. Shell Programming and Scripting

Can I combine these two commands into one?

sed -e :a -e 's/<*>//g;/</N;//ba' a2.html -removes html tags and sed -i 's/YOURS TRULY/Joe Bob/' a2.html Replaces a string with another string can i make it into one string? (2 Replies)
Discussion started by: boyboy1212
2 Replies

7. Shell Programming and Scripting

Combine two lists From Multiple Grep commands.

I'm working with a file with an xml structure. I'd like to parse it down to just the bits i want. Here is and example of the file <message id="96352877" method="status"> <date rfc="Sat, 12 Mar 2011 16:13:15 -0600" unix="1299967995" /> <services> <service id="facebook"... (4 Replies)
Discussion started by: Erulisseuiin
4 Replies

8. UNIX for Dummies Questions & Answers

Combine commands

Hi, i tried to combine grep with find and it didnt work grep 'find dirname filename" i also would like that the file will be sorted in the way. thanks a lot. (2 Replies)
Discussion started by: Spoiler
2 Replies

9. Shell Programming and Scripting

Combine Two Commands Output

How i can combine output of two commands in one file.......i tried this but it is not working although each command is working good seperately..... head -1 filename | tail -1 filename i think there is problem with command concatenator? (16 Replies)
Discussion started by: 33junaid
16 Replies

10. AIX

combine two vg spaces

Hello, I'm a newbie on this AIX/Unix. I'm trying to combine the space of /testing1/ to /testing2/, so that /testing2/ may have more space. How do I accomplish this? I guess I have to unmount /testing1/ from /apple26lv first... but after that I'm not sure how this can be accomplished? ... (3 Replies)
Discussion started by: cchiang12
3 Replies
Login or Register to Ask a Question