The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep help flood Shell Programming and Scripting 3 06-05-2008 10:14 PM
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 04:10 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 01:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-24-2006 09:20 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-15-2006
Registered User
 

Join Date: Nov 2005
Posts: 5
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.
Reply With Quote
Forum Sponsor
  #2  
Old 01-15-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
egrep 'HR|FS' myfile

Cheers
ZB
Reply With Quote
  #3  
Old 01-15-2006
Registered User
 

Join Date: Nov 2005
Posts: 5
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?
Reply With Quote
  #4  
Old 01-15-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,248
To remove a file that is less than 10 bytes...
Code:
if [[ $(wc -c < $file) -lt 10 ]]
then
  rm $file
fi
Reply With Quote
  #5  
Old 01-15-2006
Registered User
 

Join Date: Nov 2005
Posts: 5
Thanks again.

You guys know everything!

Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0