shell echo 命令中转义单引号

使用 '\'' 代替要转义的单引号,如下所示

[root@localhost ~]# echo 'alias ll='\''ls -l'\''' > text.txt
[root@localhost ~]# cat text.txt
alias ll='ls -l'
[root@localhost ~]#

 

posted @ 2023-05-11 15:42  Nihaorz  阅读(143)  评论(0)    收藏  举报