Results 1 to 8 of 8

Thread: convert a column to row output?

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default convert a column to row output?

    Getting tired of cut-and-paste...so I thought I would post a question.

    how do I change this column output to a Single Row?

    from this:

    # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}'
    /dev/dsk/c6t0d5
    /dev/dsk/c11t0d5
    /dev/dsk/c15t0d5
    /dev/dsk/c18t0d5
    /dev/dsk/c7t0d5
    /dev/dsk/c10t0d5
    /dev/dsk/c14t0d5
    /dev/dsk/c19t0d5


    to this:
    /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5 /dev/dsk/c10t0d5 /dev/dsk/c14t0d5 /dev/dsk/c19t0d5



    any assistance would be appreciated

    manny

  2. #2
    Junior Member
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    found a solution

    $ vgdisplay -v /dev/vgeva05 | awk '{print $3}' | awk 'END {print line} /dsk/ { line = line " " $0 }'
    /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5 /dev/dsk/c10t0d5 /dev/dsk/c14t0d5


    enjoy,

    manny

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    another variation:

    Code:
    $ vgdisplay -v /dev/vgeva05 | awk 'END {print line}  /dsk/ { line = line " " $3 }'
     /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5 /dev/dsk/c10t0d5 /dev/dsk/c14t0d5 /dev/dsk/c19t0d5

  4. #4
    Junior Member
    Join Date
    Mar 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    have you tried
    Code:
      echo $(vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}')
    or may be just
    Code:
      echo $(vgdisplay -v /dev/vgeva05 | awk '/dsk/{print $3}')

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    thanks for the reply frog, but I was looking to convert the column to "row" output.

    solution was in previous post

  6. #6
    Junior Member
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Well.. If you want to convert it into row output.. This also might have worked for you..

    Command HERE | xargs

    Will automatically convert it into arguments.

  7. #7
    Junior Member
    Join Date
    Sep 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default convert column into single line

    Try out.....
    echo $(vgdisplay -v|grep "PV Name"|awk -F " " '{print $3}')

  8. #8
    Senior Member
    Join Date
    Jun 2007
    Location
    Hyderabad, AP, India
    Posts
    806
    Thanks
    44
    Thanked 55 Times in 48 Posts
    Rep Power
    13

    Default

    This is the code i use for this purpose
    Code:
    sed ':a;N;$!ba;s/\n/ /g'
    Thanks,
    Surendra Kumar Anne
    Linux: Fast, friendly, flexible and .... free!
    Support Open source.
    http://www.linuxnix.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Linux convert doc to pdf file
    By myfoot in forum CentOS / RHEL / Fedora
    Replies: 2
    Last Post: 25th April 2011, 05:17 PM
  2. To remove a particular column from a file
    By devi_vi in forum Shell scripting
    Replies: 7
    Last Post: 6th September 2010, 12:00 PM
  3. mysql delete column
    By jerry in forum Databases servers
    Replies: 1
    Last Post: 4th February 2010, 10:11 PM
  4. [Solved] Line and column count in awk
    By raj in forum Shell scripting
    Replies: 2
    Last Post: 9th January 2010, 10:16 AM
  5. How to convert an excel file into PDF?
    By jimcp in forum Linux software
    Replies: 1
    Last Post: 8th July 2009, 07:20 PM

Posting Permissions

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