System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

SOLVED
Go to solution
Kennedy G. Doss
Regular Advisor

Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

Dear System Administrators:

 

On the HP-UX side of the house I have been using "bdfmegs.sh" script by Bill Hassel to obtain pleasant outputs in a single line. Is there anything similar to produce outputs on a LINUX Server? Any input from your end would be most appreciated.

 

Regards,

-Kennedy

 

 

P.S. This thread has been moved from HP-UX > System Administration to Linux > sysadmin - HP Forums Moderator

6 REPLIES
Patrick Wallek
Honored Contributor

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

No need for a special script. Just add the '-P' to your df command.

 

[root@rh6x ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_atl10rh6x-lv_root
                      5.5G  1.3G  4.0G  24% /
tmpfs                1004M     0 1004M   0% /dev/shm
/dev/sda1             485M   30M  430M   7% /boot


[root@rh6x ~]# df -Ph
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_atl10rh6x-lv_root  5.5G  1.3G  4.0G  24% /
tmpfs                1004M     0 1004M   0% /dev/shm
/dev/sda1             485M   30M  430M   7% /boot

 

It's not quite as pretty, but the information is all on one line.

 

Kennedy G. Doss
Regular Advisor

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

Thanks a lot. That helps! Thanks for taking the time and writing back.

RAJD1
Valued Contributor
Solution

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

Hi Kennedy,

 

You can try something like this , adding to Patrick's command, to get more alligned output with your df command: 

(I dont have system to test it now , but you can give it a try, ) 

 

# df -Ph | awk '{printf "%-35s%-10s%-10s%-10s%-5s%s",$1,$2,$3,$4,$5,$6}'

 

 

Hth,

Raj D.

 

 

 

Patrick Wallek
Honored Contributor

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

You were close with:

 

df -Ph | awk '{printf "%-35s%-10s%-10s%-10s%-5s%s",$1,$2,$3,$4,$5,$6}'

 

You just need a "\n" to add a new line.

 

df -Ph | awk '{printf "%-35s%-10s%-10s%-10s%-5s%s\n",$1,$2,$3,$4,$5,$6}'

 

Kennedy G. Doss
Regular Advisor

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

Thanks a lot Patrick. Now my outputs look way better!!

Kennedy G. Doss
Regular Advisor

Re: Script to list "df -h" output in a single Line - Similar to bdfmegs.sh on RHEL

Thanks a lot for the suggestion Raj. I really appreciate you taking the time and responding.