LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2008, 07:46 AM   #1
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Rep: Reputation: 30
change output format for df


Hi,

I'm looking to get back the usage % and partition name by using df. Here's my output from normal df

Code:
[root@localhost scripts]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       37G   24G   11G  69% /
/dev/hda1              99M  9.9M   84M  11% /boot
/dev/hdb1              76G   43G   33G  57% /mnt/hdb
/dev/shm              220M     0  220M   0% /dev/shm
No i know i can use grep and awk to fish out what i want,but my problem is the first line. It runs over two lines,i.e for the last rows my Use% is variable $5,but for the second row it is $4 because of the first drive expanding over two rows, so something like this happens..

Code:
[root@localhost scripts]# df -h | grep -vE "^Filesystem|shm|boot" | awk '{print $5 " " $6}'

/
57% /mnt/hdb
I want the ouput to be

Code:
69% /
57% /mnt/hdb
Any ideas how i can chagne the command to do this?

Thanks
 
Old 04-21-2008, 08:00 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Use
Code:
df -Ph
 
Old 04-21-2008, 08:04 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,066

Rep: Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594Reputation: 2594
Check NR ???
 
Old 04-21-2008, 08:08 AM   #4
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by colucix View Post
Use
Code:
df -Ph
Thanks,this worked. I missed that one....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Format bash output ceashton Programming 3 08-17-2007 12:16 PM
last command output format bujecas Linux - General 1 10-12-2006 09:54 AM
i need rpm output in table format Uday123 Fedora 1 12-17-2005 05:15 PM
tool to format report output from mysql? alar Linux - General 0 08-03-2004 08:16 PM
C++ format float number output keefaz Programming 3 06-06-2004 02:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration