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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM