Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个 awk statemnt 并且工作正常
awk '{a= a","$1}END{print a}' file.txt
我希望在我的输出中我的 $1 字段应该用单引号括起来
怎么能这样做
单程:
awk -v q="'" '{a= a","q$1q}END{print a}' file.txt
其他方式:
awk '{a= a",\x27"$1"\x27"}END{print a}' file.txt
awk '{a= a",'"'"'"$1"'"'"'"}END{print a}' file.txt
其他:
awk '{a= a",'\''"$1"'\''"}END{print a}' file.txt