skip reading certain lines in a file | 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 !!

skip reading certain lines in a file

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-24-2007
paulsew paulsew is offline
Registered User
 
Join Date: Nov 2003
Last Activity: 8 September 2009, 9:16 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
skip reading certain lines in a file

How can I exclude reading lines in a file that contains the following:

filesystem:/home/pach/liv_patches 128005120 88456640 37270758 71% /home/patches

That is, all lines that contain and begins with filesystem: should not be processed/read from a file
Sponsored Links
    #2  
Old 02-24-2007
hegemaro hegemaro is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 3 February 2012, 11:19 PM EST
Location: Schenectady, NY
Posts: 134
Thanks: 0
Thanked 2 Times in 2 Posts
sed -e "/^filesystem:/d" filename

or

grep -v "^filesystem:" filename
Sponsored Links
    #3  
Old 03-26-2007
bishnu.bhatta bishnu.bhatta is offline
Registered User
 
Join Date: Mar 2007
Last Activity: 25 April 2013, 8:11 AM EDT
Location: Bangalore,India
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Tools

Hi hagemaro,

I think your solution will only serve the purpose when the word "filesystem" is at the begining.

Please correct if i am wrong.

Cheers
    #4  
Old 03-26-2007
dennis.jacob's Avatar
dennis.jacob dennis.jacob is offline Forum Advisor  
Registered User
 
Join Date: Feb 2007
Last Activity: 30 March 2014, 9:33 AM EDT
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 12 Times in 11 Posts
Try this out... This will not show any lines containing the specified word.


Code:
 sed '/filesystem/d' filename

grep 'filesystem' filename

Sponsored Links
    #5  
Old 03-26-2007
ghostdog74 ghostdog74 is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 9 November 2014, 12:24 AM EST
Posts: 2,669
Thanks: 0
Thanked 18 Times in 18 Posts
Quote:
Originally Posted by jacoden
Try this out... This will not show any lines containing the specified word.


Code:
 sed '/filesystem/d' filename

grep 'filesystem' filename

user wants to exclude lines with "filesystem", so the grep should have -v? anyway, i noticed this thread was started weeks ago.
Sponsored Links
    #6  
Old 03-26-2007
dennis.jacob's Avatar
dennis.jacob dennis.jacob is offline Forum Advisor  
Registered User
 
Join Date: Feb 2007
Last Activity: 30 March 2014, 9:33 AM EDT
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 12 Times in 11 Posts
Quote:
Originally Posted by ghostdog74
user wants to exclude lines with "filesystem", so the grep should have -v? anyway, i noticed this thread was started weeks ago.
Sorry ..it was a typo.. It should be grep -v ...
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
skip lines while reading a file bankimmehta Shell Programming and Scripting 4 04-07-2011 04:42 AM
awk: skip x lines and ssh anthonyraj75 Shell Programming and Scripting 7 03-12-2010 03:11 PM
awk - skip x lines and ssh anthonyraj75 Shell Programming and Scripting 1 03-04-2010 11:16 AM
How to skip lines which don't begin with a number shira Shell Programming and Scripting 10 01-10-2010 12:12 AM
How to skip lines in a KSH? divak Shell Programming and Scripting 1 12-09-2009 06:19 AM



All times are GMT -4. The time now is 11:26 PM.