linux 中 awk命令如何输出双引号和单引号

小鲨鱼2018 / 2023-05-12 / 原文

 

001、双引号

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
1
2
3
4
5
[root@PC1 test]# awk '{print $0, "\""}' a.txt    ## 输出双引号
1 "
2 "
3 "
4 "
5 "

 

002、单引号

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
1
2
3
4
5
[root@PC1 test]# awk '{print $0, "'\''"}' a.txt    ## 输出单引号
1 '
2 '
3 '
4 '
5 '