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 $ 

 

posted @ 2020-12-17 00:30  亦幻  阅读(927)  评论(1编辑  收藏  举报