Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

df command - tidy up the output 1

Status
Not open for further replies.

mikieo

IS-IT--Management
Oct 6, 2003
15
0
0
GB
when I do df I get a rather difficult to read screen the data is not lined up correctly is there anyway I can pass it to another command to make it look ok ?

cheers
m
 
Try :
df|awk -F" " '{printf("%s\t%s\t%s\n",$1,$2,$3)}'

(This is only showing the first 3 fields - expand as required - add more tabs (\t) as req'd too)
HTH

Dickie Bird (:)-)))
 
fantasic dickie bird ! glad to see your not missing the test cricket now that you've taken up programming :)
 
And even better - if you've got some long filesystem names :
df|awk -F" " '{ if (length($1) > 15 ){printf("%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} else {printf("%s\t\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} } '

Right - now to get back to the crease !

Dickie Bird (:)-)))
 
knocked for six... spot on my man...

 
Uh, didn't work:

Filesystem 512-blocks Free %Used Iused
/dev/hd4 1048576 548432 48% 4715
/dev/hd2 7602176 408672 95% 86888
/dev/hd9var 917504 470288 49% 4620
/dev/hd3 393216 326256 18% 450
/dev/hd1 65536 59544 10% 681
/dev/optlv 458752 189608 59% 433
/dev/tftpbootlv 65536 54312 18% 61
/dev/newspdatalv 70516736 33252024 53% 18559
/dev/neworklv 35258368 30915104 13% 1320
/dev/cd0 159408 0 100% 39852
 
Nor for me:

Filesystem 512-blocks Free %Used Iused
/dev/hd4 65536 37288 44% 2409
/dev/hd2 7471104 0 100% 69211
/dev/hd9var 65536 47128 29% 537
/dev/hd3 851968 824960 4% 51
/dev/hd1 65536 62944 4% 98
/proc - - - -
/dev/hd10opt 65536 38224 42% 608
/dev/redo1_lv 32768000 13181712 60% 70
/dev/redo2_lv 32768000 13397592 60% 67
/dev/archive_lv 65536000 63478840 4% 25
/dev/oradata_lv 170393600 129670392 24% 67
/dev/oraindex_lv 170393600 133491272 22% 65
/dev/ifsdoc_lv 403701760 402878112 1% 63
/dev/lv00 30015488 16722608 45% 65576
 
Kind of worked for me, it was neater but not all the information...maybe your bowled me a googilie..!?

Filesystem 512-blocks Free %Used Iused
/dev/hd4 4521984 2920048 36% 5095
/dev/hd2 11862016 1753432 86% 53608
/dev/hd9var 327680 291832 11% 478
/dev/hd3 4063232 3935544 4% 57
/dev/hd1 65536 60456 8% 103
/dev/stage817_64 2228224 188064 92% 5145
/dev/817_64 6619136 2232192 67% 43149
/dev/805_64 131072 104400 21% 418
/dev/mntDEV 1572864 1080464 32% 2996
/dev/sapDEV 1048576 711792 33% 379
/dev/utils 262144 99024 63% 82
/dev/DEVsaparch 15794176 12091080 24% 124
/dev/DEVsapreorg 7667712 1726080 78% 615
/dev/DEVsapbackup 3145728 2068808 35% 203
/dev/DEVsapcheck 655360 591008 10% 76
/dev/DEVsaptrace 589824 430680 27% 108
/dev/DEVoriglogA 262144 162328 39% 21
/dev/DEVoriglogB 262144 171784 35% 19
/dev/DEVmirrlogA 262144 171784 35% 19
/dev/DEVmirrlogB 262144 130760 51% 20
/dev/DEVsapdata1 13369344 2044408 85% 80
/dev/DEVsapdata2 15728640 3934560 75% 25
/dev/DEVsapdata3 11272192 3846512 66% 23
/dev/DEVsapdata4 12845056 2076792 84% 29
/dev/DEVsapdata5 23592960 3519072 86% 29
/dev/DEVsapdata6 20447232 2994816 86% 47
/dev/lv00 851968 137000 84% 1459
 
OK - the final ball of the over:

df|awk -F" " '{
if ($1=="Filesystem")
{printf("%s\t\t%s%s %s\t%s\t%s\t%s\t%s %s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9)}
else {
if (length($1) < 16 )
{printf(&quot;%s\t\t%s\t%s\t%s\t%s\t%s\t%s\n&quot;,$1,$2,$3,$4,$5,$6,$7)}
else
{printf(&quot;%s\t%s\t%s\t%s\t%s\t%s\t%s\n&quot;,$1,$2,$3,$4,$5,$6,$7)}
}
} '

gives me :
Filesystem TotalKB free %used iused %iused Mounted on
/dev/hd4 16384 6108 62% 1114 27% /
/dev/hd9var 28672 14864 48% 551 6% /var
/dev/hd2 217088 32868 84% 10688 19% /usr
/dev/hd3 98304 94428 3% 128 0% /tmp
/dev/hd1 192512 37764 80% 9580 19% /home
mickey:/local_backup 4096 3120 23% - - /local_backup
/dev/bgslv 53248 24748 53% 172 1% /bgs
/dev/sysscriptslv 12288 10960 10% 152 3% /SYSTEM_SCRIPTS
/dev/logslv 16384 12312 24% 89 2% /logs
/dev/dvgprogsource 155648 15596 89% 11038 28% /program_source
/dev/dvgusdata 409600 174592 57% 2135 2% /usdata
/dev/dvgtrams 1048576 540484 48% 3347 1% /trams
/dev/dvgdata 1228800 165828 86% 5156 1% /data
/dev/dvgspoolprt 81920 77620 5% 225 1% /spool_printed
/dev/dvgruntime 278528 37288 86% 9799 14% /runtime
/dev/dvgreport 237568 156748 34% 946 1% /report
/dev/lv01 2007040 1410208 29% 53 0% /DRbackup
/dev/lvdiskb 1572864 1012428 35% 61 0% /lb


Hmmmmmmm - tabs don't match up so good on this display - All were perfect on my telnet session !!!!!!


Dickie Bird (:)-)))
 
Hi,
French says : &quot;Why to do it easy when we can do it more complex!&quot;

try this and adjust the numbers accoridng to the length of your filesystems :

df|awk '{
printf(&quot;%+20s %+8s\t%+8s %+4s\t%+8s %+4s %.20s %s %s\n&quot;,$1,$2,$3,$4,$5,$6,$7,$8,
$9)
} '

%+20s adjust the string to the right within 20 chars
%-20s adjust the string to the left within 20 chars
%.20s truncate the string to the 20 first chars
see man printf for more details
 
aau that's good for me thx


Dickie Bird

the bat's man holding the bowlers willy..... classic line!
thanks dude it's been fun and educational
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top