The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parsing output lochraven Shell Programming and Scripting 6 08-15-2008 04:38 PM
parsing output looza Shell Programming and Scripting 6 07-15-2008 08:57 PM
parsing output from SQL querry ludvig Shell Programming and Scripting 7 10-23-2007 05:42 AM
parsing output from a diff command... kam Shell Programming and Scripting 5 05-29-2007 11:26 PM
parsing output from ls command ajaya Shell Programming and Scripting 3 05-10-2006 10:22 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-24-2009
cjjoy cjjoy is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 12
parsing output of system()

Hi,

From the above output of df command I need to parse only 43G (available space) and display it.

root@localhost:> df -h /vol1/joy

Filesystem Size Used Avail Capacity Mounted on
/vol1/joy 180G 137G 43G 76% /backup

I am using the system command in the following way. Let me know if there is still an efficient way of doing it.

Code:
    printf("Free space: ");
     system("df  /vol1/joy | awk '{print $3}' | tail -n 1");
  #2 (permalink)  
Old 08-24-2009
ryandegreat25 ryandegreat25 is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 236
try..
Code:
-bash-3.2$ df -h /filesystem | awk 'END {print $3}'
13G
-bash-3.2$
  #3 (permalink)  
Old 08-24-2009
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by ryandegreat25 View Post
try..
Code:
-bash-3.2$ df -h /filesystem | awk 'END {print $3}'
13G
-bash-3.2$
To get the 'Free Space' prefix, use ...{ print "Free Space:",$3 }'
  #4 (permalink)  
Old 08-25-2009
cjjoy cjjoy is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 12
Thanks a bunch...Got what I needed..
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0