如何在awk中显示单引号

时间:2021-02-08 19:40:07

I have this awk statemnt and its working fine

我有这个awk statemnt并且工作正常

awk '{a= a","$1}END{print a}' file.txt

I want that in my output my $1 field shoube surrounded with single quotes

我希望在我的输出中我的$ 1字段shoube用单引号包围

how can do that

怎么能这样做

1 个解决方案

#1


1  

One way:

awk -v q="'" '{a= a","q$1q}END{print a}' file.txt

Another way:

awk '{a= a",\x27"$1"\x27"}END{print a}' file.txt

Another way:

awk '{a= a",'"'"'"$1"'"'"'"}END{print a}' file.txt

Another:

awk '{a= a",'\''"$1"'\''"}END{print a}' file.txt

#1


1  

One way:

awk -v q="'" '{a= a","q$1q}END{print a}' file.txt

Another way:

awk '{a= a",\x27"$1"\x27"}END{print a}' file.txt

Another way:

awk '{a= a",'"'"'"$1"'"'"'"}END{print a}' file.txt

Another:

awk '{a= a",'\''"$1"'\''"}END{print a}' file.txt