Print header and some lines | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Print header and some lines

Shell Programming and Scripting


Tags
awk

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-14-2013
netdbaind netdbaind is offline
Registered User
 
Join Date: Aug 2012
Last Activity: 24 July 2014, 2:03 AM EDT
Posts: 44
Thanks: 7
Thanked 0 Times in 0 Posts
Wrench Print header and some lines

HI ,

i have to print the first header of df -h (Filesystem Size Used Avail Use% Mounted on)and line which conatin size Network path only.


Code:
Filesystem            Size  Used Avail Use% Mounted on
/test/sda3              35G  1.8G   32G   6% /
/test/sda10            7.8G  1.1G  6.3G  15% /usr
/test/sda12            3.9G   73M  3.7G   2% /usr/local
/test/sda9             7.8G  329M  7.1G   5% /var
/test/sda8             7.8G  3.6G  3.9G  49% /opt
/test/sda7              16G  1.4G   14G  10% /tmp
                      4.0T  523G  3.5T  13% /Network/Test

Sponsored Links
    #2  
Old 02-14-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 29 July 2014, 5:18 PM EDT
Location: Aachen, Germany
Posts: 3,923
Thanks: 62
Thanked 932 Times in 884 Posts

Code:
$ sed -n '1p; /Network/p' file
Filesystem            Size  Used Avail Use% Mounted on
                      4.0T  523G  3.5T  13% /Network/Test
$ awk 'NR==1 || /Network/' file
Filesystem            Size  Used Avail Use% Mounted on
                      4.0T  523G  3.5T  13% /Network/Test

The Following User Says Thank You to RudiC For This Useful Post:
netdbaind (02-15-2013)
Sponsored Links
    #3  
Old 02-14-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 29 July 2014, 6:45 AM EDT
Posts: 1,797
Thanks: 108
Thanked 514 Times in 467 Posts
As described in man df , you can have the desired item (device path or mount path) as extra argument:

Code:
df -h /Network/Test

    #4  
Old 02-14-2013
Vikram_Tanwar12 Vikram_Tanwar12 is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 21 November 2013, 3:32 AM EST
Posts: 168
Thanks: 13
Thanked 10 Times in 10 Posts
You can also try this.


Code:
df -h | grep -w 'Filesystem\|Network'

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
awk print header as text from separate file with getline sdf Shell Programming and Scripting 4 12-14-2011 05:24 PM
Need awk help to print specific columns with as string in a header arv_cds Shell Programming and Scripting 21 05-27-2011 11:31 AM
print lines AFTER lines cointaining a regexp (or print every first and fourth line) kmkocot Shell Programming and Scripting 1 07-06-2010 09:57 PM
print lines except the header madfox Shell Programming and Scripting 2 01-21-2010 08:41 AM
Strip 3 header lines and 4 trailer lines ganesh123 Shell Programming and Scripting 9 03-10-2007 04:15 PM



All times are GMT -4. The time now is 08:56 PM.