Grep OR | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Grep OR

UNIX for Dummies Questions & Answers


Tags
grep or

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-15-2006
reebz reebz is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 17 January 2006, 7:28 PM EST
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Grep OR

Hi,

I want to grep for both "FS" and "HR" at the same time, but return lines that contain either entry.

So, I want it to be:

cat file.txt | grep HR or FS

How do I do this?

Thanks in advance.
Sponsored Links
    #2  
Old 01-15-2006
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 24 Times in 23 Posts
egrep 'HR|FS' myfile

Cheers
ZB
Sponsored Links
    #3  
Old 01-15-2006
reebz reebz is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 17 January 2006, 7:28 PM EST
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the quick answer, it worked a treat.

Also, while I'm here, one more quick question

I'm grepping for those lines above, appending them to a new file and then doing a:

test -s

except that some files have a new line or one or two characters left in them and are not deleting.

Is there a way to delete a file that is less than, say, 10 bytes?
    #4  
Old 01-15-2006
Ygor's Avatar
Ygor Ygor is offline Forum Advisor  
Advisor
 
Join Date: Oct 2003
Last Activity: 2 May 2014, 7:14 AM EDT
Location: 54.23, -4.53
Posts: 1,801
Thanks: 1
Thanked 111 Times in 98 Posts
To remove a file that is less than 10 bytes...
Code:
if [[ $(wc -c < $file) -lt 10 ]]
then
  rm $file
fi

Sponsored Links
    #5  
Old 01-15-2006
reebz reebz is offline
Registered User
 
Join Date: Nov 2005
Last Activity: 17 January 2006, 7:28 PM EST
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks again.

You guys know everything!

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bash - CLI - grep - Passing result to grep through pipe jcdole UNIX for Dummies Questions & Answers 1 04-29-2012 06:20 PM
Advanced grep'in... grep for data next to static element. SysAdm2 UNIX for Dummies Questions & Answers 2 01-05-2011 12:59 PM
grep for certain files using a file as input to grep and then move anita07 Shell Programming and Scripting 2 12-10-2009 03:59 AM
| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax MykC UNIX for Dummies Questions & Answers 4 10-15-2009 10:52 AM
| help | unix | grep - Can I use grep to return a string with exactly n matches? MykC UNIX for Dummies Questions & Answers 7 10-13-2009 01:57 PM



All times are GMT -4. The time now is 04:18 AM.