我们需要打印
目标ID = “123”
AssayID = “456”,
awk -F\", 'BEGIN{FS=",";OFS=",";} {print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$13,$14,$15,$16,$17,$18,$19,$20,$12}' VrtAssay_123_target_456_assay_Detail2.csv > VrtAssay_123_target_456_assay_Detail2_reorder.csv
一个。我们尝试:
printf "awk -F"\""," 'BEGIN{FS=\",\";OFS=\",\";} {print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$20,\$12,\$13,\$14,\$15,\$16,\$17,\$18,\$19}' VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail2_average.csv > VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail3.csv"
B中。或回声
echo "awk -F"\"", 'BEGIN{FS=\",\";OFS=\",\";} {print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$20,\$12,\$13,\$14,\$15,\$16,\$17,\$18,\$19}' VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail2_average.csv > VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail3.csv"
两者都给(\已消失)
awk -F", 'BEGIN{FS=",";OFS=",";} {print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$13,$14,$15,$16,$17,$18,$19,$20,$12}' VrtAssay_123_target_456_assay_Detail2.csv > VrtAssay_123_target_456_assay_Detail2_reorder.csv
℃。如果我们尝试
printf "awk -F\\", 'BEGIN{FS=\",\";OFS=\",\";} {print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$20,\$12,\$13,\$14,\$15,\$16,\$17,\$18,\$19}' VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail2_average.csv > VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail3.csv"
这些将提供
的错误消息Unmatched ".
d。如果我们尝试
echo "awk -F\\", 'BEGIN{FS=\",\";OFS=\",\";} {print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$20,\$12,\$13,\$14,\$15,\$16,\$17,\$18,\$19}' VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail2_average.csv > VrtAssay_${TargetIDs}_target_${AssayID}_assay_Detail3.csv"
这给了我们
Unmatched ".
不管有什么大师可以提供一些解决方案吗?
答案 0 :(得分:3)
任何这些工作,您只需要确保所有内容都正确转义:
$ echo 'awk -F\",'
$ echo awk -F\\\",
$ echo "awk -F\\\","
shell的解析规则基本上是:
'single quotes'
内,除了单引号之外的所有内容都按字面解释;要包含文字单引号,您需要关闭单引号,然后使用双引号来获取它。"double quotes"
内,必须使用反斜杠转义双引号和反斜杠。因此,文字双引号为\"
,字面反斜为\\
,字面反斜杠和双引号为\\\"
。如果你只是写\\"
,那就是一个字面反斜杠,然后是一个结束语。答案 1 :(得分:2)
使用单引号而不是双引号,例如:
echo 'awk -F\",'
答案 2 :(得分:1)
尝试一下,
echo 'awk -F\",'
如果我们将输入括在单引号内,它将按原样打印。