[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Question: variables and newlines
From: |
Alexander Elgert |
Subject: |
Question: variables and newlines |
Date: |
Thu, 22 Aug 2002 19:39:53 +0200 |
User-agent: |
Mutt/1.4i |
Hello,
I tried to set newline chars at the end of a variable.
But it does not seem to be possible:
$ IFS="" x="$(echo -en "www\n\n\n")"; echo -n "$x" | xxd
0000000: 7777 77 www
$
I figured out that any ending newline chars are cut, but not the chars
in the front nor between. So I added a space after a newline and
removed it again, this works:
| |||||||||||
v vvvvvvvvvvv
$ IFS="" x="$(echo -en "www\n\n\n ")"; x="${x% }"; echo -n "$x" | xxd
0000000: 7777 770a 0a0a www...
$
How do I add newlines at the end of a string without "bad tricks" ?
Greetings,
Alexander
--
Alexander Elgert
Public Gruppe
RechnerBetriebsGruppe TU Darmstadt (FB 20) Tel: +49 06151 16-4333
Raum: S1/13 11a (alt 25/11a)
FAQ2: http://www.informatik.tu-darmstadt.de/RBG/service/FAQ2/
- Question: variables and newlines,
Alexander Elgert <=