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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

df -k output into comma delimited file 3

Status
Not open for further replies.

kHz

MIS
Dec 6, 2004
1,359
US
If I run df -k I get:

Filesystem 512-blocks Free %Used Iused %Iused Mounted on
/dev/hd4 1310720 1147504 13% 2982 1% /
/dev/hd2 6815744 1632352 77% 53740 7% /usr
/dev/hd9var 131072 51616 61% 1025 7% /var
/dev/hd3 524288 96576 82% 1344 3% /tmp
/dev/hd1 131072 120296 9% 448 3% /home

What I want is to put the contents into a comma delimited file starting on line 2 (don't need the header):

/dev/hd4,1310720,1147504,13%,2982,1%,/
/dev/hd2,6815744,1632352,77%,53740,7%,/usr
/dev/hd9var,131072,51616,61%,1025,7%,/var
/dev/hd3,524288,96576,82%,1344,3%,/tmp
/dev/hd1,131072,120296,9%,448,3%,/home

Thanks!!
 
A starting point:
df -k | sed '1d;s! *!,!g' > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
df -k | nawk -v OFS="," 'FNR>1 {$1=$1;print}'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
or:
df -k | sed -n '2,$s! *!,!gp'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top