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