Skip to content

Instantly share code, notes, and snippets.

@bingoohuang
Created July 16, 2015 11:14
Show Gist options
  • Save bingoohuang/687d596a62735bc18af3 to your computer and use it in GitHub Desktop.
Save bingoohuang/687d596a62735bc18af3 to your computer and use it in GitHub Desktop.
convert df output with awk
[root@iZ25p1jt074Z ~]# df -m|awk 'NR==1{for(i=1;i<=NF;i++){ix[i]=$i}} (NR>1){for(i=1;i<=NF-1;i++){printf "%s:%s,",ix[i],$i} printf "%s:%s\n",ix[NF],$NF}'
Filesystem:/dev/xvda1,1M-blocks:20158,Used:12464,Available:6671,Use%:66%,Mounted:/
Filesystem:tmpfs,1M-blocks:4096,Used:0,Available:4096,Use%:0%,Mounted:/dev/shm
Filesystem:/dev/xvdb1,1M-blocks:201581,Used:9433,Available:181909,Use%:5%,Mounted:/mnt
[root@iZ25p1jt074Z ~]#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment