shell echo 命令中转义单引号
使用 '\'' 代替要转义的单引号,如下所示
[root@localhost ~]# echo 'alias ll='\''ls -l'\''' > text.txt [root@localhost ~]# cat text.txt alias ll='ls -l' [root@localhost ~]#
使用 '\'' 代替要转义的单引号,如下所示
[root@localhost ~]# echo 'alias ll='\''ls -l'\''' > text.txt [root@localhost ~]# cat text.txt alias ll='ls -l' [root@localhost ~]#