0
我有一個awk
,似乎很直接,但我似乎有問題。在下面的文件中,如果$5
以(
開頭,則在該字符串末尾添加)
。但if
$ 5 does not start with a
(then nothing is done. The out is separated by a tab. The
awk is almost right but I am not sure how to add the condition to only add a
)if the field starts with a
(`。謝謝:)。awk添加右括號如果字段以開括號開頭
文件
chr7 100490775 100491863 chr7:100490775-100491863 ACHE
chr7 100488568 100488719 chr7:100488568-100488719 ACHE;DJ051769
chr1 159174749 159174770 chr1:159174749-159174770 (ACKR1
chr1 159175223 159176240 chr1:159175223-159176240 (ACKR1
AWK試圖
awk -v OFS='\t' '{print $1,$2,$3,$4,""$5")"}' file
電流輸出
chr7 100490775 100491863 chr7:100490775-100491863 ACHE)
chr7 100488568 100488719 chr7:100488568-100488719 ACHE;DJ051769)
chr1 159174749 159174770 chr1:159174749-159174770 (ACKR1)
chr1 159175223 159176240 chr1:159175223-159176240 (ACKR1)
期望的輸出(線1和2不採取任何行動,但線3和4具有)
添加到末尾)
chr7 100490775 100491863 chr7:100490775-100491863 ACHE
chr7 100488568 100488719 chr7:100488568-100488719 ACHE;DJ051769
chr1 159174749 159174770 chr1:159174749-159174770 (ACKR1)
chr1 159175223 159176240 chr1:159175223-159176240 (ACKR1)
非常感謝您的幫助和解釋:)。 – Chris