bash原样输出字符串中的换行
➜ code $ cat test.sh #!/bin/bash nr="`cat -`"\" echo "$nr" echo $nr echo "[" $nr "]" echo "==============" echo "[" "$nr" "]" echo "==============" echo "["$nr"]" echo "==============" cp_nr1="<$nr>" cp_nr2="<"$nr">" cp_nr3="<""$nr"">" echo "==============" echo "$cp_nr1" echo "==============" echo "$cp_nr2" echo "==============" echo "$cp_nr3" echo "==============" echo $cp_nr1 echo "==============" echo $cp_nr2 echo "==============" echo $cp_nr3 ➜ code $ bash test.sh < test.in 123 asd" 123 asd" [ 123 asd" ] ============== [ 123 asd" ] ============== [123 asd"] ============== ============== <123 asd"> ============== <123 asd"> ============== <123 asd"> ============== <123 asd"> ============== <123 asd"> ============== <123 asd"> ➜ code $