shell脚本中\n和\t和\r 的使用

\n :换行

[root@k8s-master01 ~]# echo -e "a\nb">>/root/ceshi.txt
[root@k8s-master01 ~]# cat ceshi.txt 

a
b

\t :制表符

[root@k8s-master01 ~]# echo -e "a\tb">>/root/ceshi.txt    #a与b中间的空位就是水平制表(制表符)。相当于敲了个tab键
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
[root@k8s-master01 ~]# echo -e "c\tb">>/root/ceshi.txt
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
c    b

 

\r :相当于回车键

[root@k8s-master01 ~]# echo -e "h\rset">>/root/ceshi.txt 
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
c    b
h
 m
liutao
      date
liadast
heast
set
46789
set
[root@k8s-master01 ~]# echo -e "\r46789">>/root/ceshi.txt
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
c    b
h
 m
liutao
      date
liadast
heast
set
46789
set
46789

 

 

\v :垂直制表符

[root@k8s-master01 ~]# echo -e "liutao\vdate">>/root/ceshi.txt
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
c    b
h
 m
liutao
      date

 

\b:相当于backspace键(后退一格)

[root@k8s-master01 ~]# echo -e "liao\bdast">>/root/ceshi.txt
[root@k8s-master01 ~]# cat ceshi.txt 

a
b
a    b
c    b
h
 m
liutao
      date
liadast

 

posted @ 2021-09-16 15:02  拥抱大海,面向天空  阅读(7035)  评论(0)    收藏  举报