Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Inserting Delimiters

    How command can i use to insert delimiters..
    eg if i redirect the output of df>abc.txt then how can i insert delimiters betweent the columns.. so that i can cut the columns like memory avilable,free etc individually and manipulate them

  2. #2
    Suppose your df output looks like this:
    /dd07                (/dev/vgdd07/lvdd07  ):  7840272 blocks    123465 i-nodes
    /dd06                (/dev/vgdd06/lvdd06  ):  4893888 blocks     77065 i-nodes
    /dd05                (/dev/vgdd05/lvdd05  ):  7637056 blocks    120264 i-nodes
    /dd04                (/dev/vgdd04/lvdd04  ):  7637088 blocks    120265 i-nodes
    /dd03                (/dev/vgdd03/lvdd03  ):  7091264 blocks    111649 i-nodes
    /dd02                (/dev/vgdd02/lvdd02  ):  8043472 blocks    126665 i-nodes
    /dd01                (/dev/vgdd01/lvdd01  ):  9168032 blocks    144350 i-nodes
    awk uses a space or spaces to delimit fields.
    df | awk 'BEGIN { total=0} 
                    total += $4
                    END{ printf("Total %d\n",total) } > abc.txt
    read up on awk
    man awk
    man gawk

  3. #3
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Another take on the same problem:
    df | awk 'BEGIN { OFS="|"; } { print $1,$2,$3,$4,$5,$6; }' > abc.txt
    The OFS special variable lets you specify a delimiter (in this case I used the pipe "|").

    This will help you if you want a delimited file to hang on to. If all you want to do is manipulate a column, then jim mcnamara's solution is probably less work. And for that matter you could use the cut program as an alternative.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts