CentOS echo
echo 与 引号 与 shell 的关系
# 引号具有保留赋值的内容,该例子中的换行符被保留。
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:05:41 /Server/datas/downloads/script ]
# a="a
b
a
c
b
d"
# shell 接收是以空格来分隔,因为 $a 没有引号,所以被 shell 展开为多个参数【其中 换行符被删除,同时将参数之间的多个空格替换为一个空格】交给 echo 处理
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:06:02 /Server/datas/downloads/script ]
# echo $a
a b a c b d
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:06:05 /Server/datas/downloads/script ]
# echo "$a"
a
b
a
c
b
d
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:06:12 /Server/datas/downloads/script ]
# b=$(echo "$a" | sort | uniq)
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:06:45 /Server/datas/downloads/script ]
# echo $b
a b c d
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:06:52 /Server/datas/downloads/script ]
# echo "$b"
a
b
c
d
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:09:59 /Server/datas/downloads/script ]
# b="$(echo "$a" | sort | uniq)"
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:10:07 /Server/datas/downloads/script ]
# echo $b
a b c d
[ root@VM-0-9-centos pts/3 2021-01-30/31@6 18:10:12 /Server/datas/downloads/script ]
# echo "$b"
a
b
c
d
posted on 2021-01-02 21:19 3L·BoNuo·Lotus 阅读(107) 评论(0) 编辑 收藏 举报