Results 1 to 2 of 2
This is my script:
$ cat Memo20
$ twoliner="This is line 1.
> This is line 2."
$ IFS="."
$ echo "$twoliner"
This is line 1.
This is line 2.
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-24-2011 #1Just Joined!
- Join Date
- Jul 2011
- Posts
- 1
having echo problems
This is my script:
$ cat Memo20
$ twoliner="This is line 1.
> This is line 2."
$ IFS="."
$ echo "$twoliner"
This is line 1.
This is line 2.
$ echo $twoliner
This is line 1
This is line 2
As you can see I lose the . in the second echo. What do I have to do to get both echos to look the same?
I am a newbie at Linux and need help
- 07-24-2011 #2Just Joined!
- Join Date
- Jun 2011
- Posts
- 36
IFS is the character to separates the text and is not displayed.
More solutions are possible:
- Take a 'newline' as IFS (hexa value of newline is 0a).
Code:$ twoliner="This is line 1. > This is line 2." $ IFS='#0a' $ echo $twoliner This is line 1. This is line 2.
- unset IFS and run 'echo -e' (see also '$ man echo')
Code:$ twoliner="This is line 1. > This is line 2." $ unset IFS $ echo -e $twoliner This is line 1. This is line 2.


Reply With Quote
