echo two command output in the same line - Shell Scripting

This is a discussion on echo two command output in the same line - Shell Scripting ; Hi, I try to write script and echo two command at the same line . echo "A" echo "B" How can I pipe above two command at the same line in text file . So, in the output text file ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: echo two command output in the same line

  1. echo two command output in the same line

    Hi,
    I try to write script and echo two command at the same line .
    echo "A"
    echo "B"

    How can I pipe above two command at the same line in text file .
    So, in the output text file , you can see below ???
    Code:
    A     B
    not
    Code:
    A
    B
    Any sugggestion ???

  2. Re: echo two command output in the same line

    Hi..

    I do not know if this helps.
    If in a script you are using A and B as variables and want to print their values, then you can simply use:
    # echo "$A $B"

    For eg.,
    # export A=1
    # export B=2
    # echo "$A $B"
    1 2

    Regds,
    R.K. #

  3. Re: echo two command output in the same line

    How about the following:

    $ echo -e "A \c " && echo "B"
    A B


    with echo the '-e' means interpret the \* properly so '\c' means to keep what comes next on the same line. Then use '&&' to execute a second statement. If you want it in a file simply send the first one to the file and then append the second:

    $ echo -e "A \c " > test && echo "B" >> test
    $ cat test
    A B

+ Reply to Thread