Find the answer to your Linux question:
Results 1 to 4 of 4
I created a simple bash script. My primary concern is how to remove the new line in the output of my script in /root/test.txt Synopsis ./script.sh foo fee Content case ...
  1. #1
    Linux Newbie
    Join Date
    Mar 2006
    Posts
    101

    how to remove new line in bash using echo

    I created a simple bash script. My primary concern is how to remove the new line in the output of my script in /root/test.txt

    Synopsis

    ./script.sh foo fee
    Content

    case $1 in
    *)
    echo -ne "
    $1
    $2" > /root/test.txt
    The output of this is


    foo
    fee
    I want to remove the new line above the foo. Is it possible?

  2. #2
    Linux Newbie
    Join Date
    Mar 2006
    Posts
    101
    Problem fixed.

    I didn't notice the '"' that it should follow $1 and forgot to remove remove -e

  3. #3
    Linux Newbie
    Join Date
    Mar 2006
    Posts
    101
    forgot to ask this.

    Can I make it short that instead of writing

    case $1 in
    *)
    echo -ne "
    $1
    $2 $3 $4 $5 $6 $7 $8 $9" > /root/test.txt
    Is there a way I can shortened the portion $2 $3 $4 $5 $6 $7 $8 $9 up to variable I want let's say $100.

    I though $[2-100] is ok but instead it do an arithmetic which was $98.

  4. #4
    Just Joined!
    Join Date
    Aug 2005
    Posts
    65
    Code:
    for((i=2;$i<$#;i++)) do echo -n "$i "; done > /root/test.txt
    can this line do it ?

Posting Permissions

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