[英]How to add quotes for awk when single and double quotes are already used?
[英]Add double quotes to variables in awk output
對於此文件中的每一行,我根據 | 進行分隔並且需要加雙引號 Here are the contents of file
ks|active|0.1|0
ks|dc|0.1|0
ks|process|0.1|0
所需 output
ALTER TABLE "ks"."active" WITH gc_grace_seconds=0;
ALTER TABLE "ks"."dc" WITH gc_grace_seconds=0;
ALTER TABLE "ks"."process" WITH gc_grace_seconds=0;
這是我正在使用的命令(它沒有將值附加到 $1 和 $2
cat table_list | awk -F '|' {'print "ALTER TABLE " $1 "." $2 " WITH gc_grace_seconds=0;" '}
output 來自我正在使用的命令
ALTER TABLE ks.active WITH gc_grace_seconds=0;
ALTER TABLE ks.dc WITH gc_grace_seconds=0;
ALTER TABLE ks.process WITH gc_grace_seconds=0;
你不需要cat
,你可以使用printf
這可能更容易獲得所需的 output
awk -F\| '{printf("ALTER TABLE \"%s\".\"\%s\" WITH gc_grace_seconds=0;\n", $1, $2)}' < table_list
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.