Results 1 to 3 of 3

Thread: bash output redirection

  1. #1
    Join Date
    Mar 2007
    Location
    Delaware, USA
    Beans
    682
    Distro
    Ubuntu 12.04 Precise Pangolin

    bash output redirection

    I would like to output an echo to the same line as the results of a db2 query instead of both being printed on separate lines. Here is an example if I am not clear.

    Code:
       
       if [ "$_input" != "$_temp" ]; then
          echo "$_input, " >> $_dataFile
       fi
    
       db2 -x "select statement" | sed 's/  */,/g' >> $_dataFile
    Right now it outputs
    Code:
    $_input
    results,from,db2
    I would like
    Code:
    $_input,results,from,db2
    TIA.
    Asus
    Intel Core 2 Duo 2.26 GHz - 4GB DDR2
    1 GB ATI Mobility Radeon HD 3650
    Atheros AR928X Wireless

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

  3. #3
    Join Date
    Mar 2007
    Location
    Delaware, USA
    Beans
    682
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: bash output redirection

    Sorry, I missed this in the echo man pages. -n will echo without a new line

    Code:
       if [ "$_input" != "$_temp" ]; then
          echo -n "$_input, " >> $_dataFile
       fi
    
       db2 -x "select statement" | sed 's/  */,/g' >> $_dataFile
    Asus
    Intel Core 2 Duo 2.26 GHz - 4GB DDR2
    1 GB ATI Mobility Radeon HD 3650
    Atheros AR928X Wireless

Bookmarks

Posting Permissions

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