\n in shell variable speichern
-
hallo,
kann mir jmd. sagen warum diesem script
echo -e "hello\nworld"; tmp=`echo -e "hello\nworld"`; echo $tmp; exit;folgendes
hello world hello worldausgibt? hätte das
hello world hello worlderwartet

-
Eine trickreiche Sache: Die Newlines sind da. Aber bevor sie an das Echo gehen, geht die Shell noch mal drüber und macht sie wieder weg. Also wieder quoten, damit die Shell das bleiben lässt:
echo -e "hello\nworld"; tmp=`echo -e "hello\nworld"`; echo "$tmp";
-
danke!