shell script to create an output file of a "df -m" command with ";" seperators

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smashzone
    New Member
    • May 2007
    • 9

    shell script to create an output file of a "df -m" command with ";" seperators

    Hi all,

    Can anyone help me with a script to produce an output file of a "df -m" command with ";" seperators. I assume its very easy but I know nothing about Linux/Unix (I'm a newbie)

    That is:
    df -m

    [philani@slayer ~]$ df -m
    Filesystem 1M-blocks Used Available Use% Mounted on
    /dev/md0 9845 4881 4464 53% /
    /dev/md1 62994 12201 47593 21% /app
    /dev/sdb1 312 25 271 9% /boot
    /dev/sda1 563166 339521 195038 64% /data
    none 1005 0 1005 0% /dev/shm

    The output file should contain something like this:

    9845;4881;4464; 53%;/
    62994;12201;475 93;21%;/app
  • ghostdog74
    Recognized Expert Contributor
    • Apr 2006
    • 511

    #2
    Code:
    df -m | awk '{OFS = ";"; $1=$1;print $0}'

    Comment

    • db2admin
      New Member
      • Apr 2007
      • 3

      #3
      Originally posted by ghostdog74
      Code:
      df -m | awk '{OFS = ";"; $1=$1;print $0}'

      Does'nt work in AIX :(

      Comment

      • db2admin
        New Member
        • Apr 2007
        • 3

        #4
        this worked :
        df -m|tr -s " \t" ","

        I was trying with
        df -m|sed 's/[ \t]{1,}/,/g'
        but did'nt worked,
        can anybody point out as what is wrong in it ? :)

        Comment

        • smashzone
          New Member
          • May 2007
          • 9

          #5
          Thanks a lot guys...it worked

          Comment

          Working...