On Tue, Apr 03, 2007 at 03:45:30PM +0100, Chris G wrote:
You missed the '-e' after the echo, but as Ted says, it looks like MJ got it.
Ah, oops, so I did. So now it's working for me too. Thanks all.
I think my problem was reading the man page for echo which says:-
-e enable interpretation of backslash escapes -E disable interpretation of backslash escapes (default)
as that doesn't suggest to me anything like what it actually does! I think what it's actually doing is echoing the characters as they *really* are when you give it -e whereas with -E it turns any white space into a single space.
No, no, no, no, no - oh dear, I've confused myself haven't I. The echo man page is quite correct and (as others have noted) all that's happening above is that echo is turning the \n into a newline.
However I now think I can get what I want and show it:-
chrisg$ fred="abcde"$'\n'"ghijk" chrisg$ echo $fred abcde ghijk chrisg$
The sequence $'\n' in bash is a string containing a single newline character (most of the other familiar \ specials work too).