我有一个模板文件A.txt
(sep = \t
):
File Name novaprime-ct043904-TB_2140.pcrd
Created By User admin
Notes
ID
Run Started 09/17/2020 01:19:12 UTC
Run Ended 09/17/2020 03:12:22 UTC
Sample Vol 30
Lid Temp 105
Protocol File Name Cll Novaprime.prcl
Plate Setup File Name CFX-TB_2140-20200916.pltd
Base Serial Number CT043904
还有第二个文件B.txt
(sep = \t
):
Cycle Well Value Target Content
1 A1 5.07368111264623 EC Unkn-01
1 A1 3.06982862746599 FT Unkn-09
1 A1 2.46545646544623 EC Unkn-01
我想将第 10 行A.txt
(以粗体显示的内容)中的信息添加到 中的新列B.txt
:Plate Setup File Name CFX-TB_2140-20200916.pltd
为了有C.txt
(sep = \t
):
Cycle Well Value Target Content Plate
1 A1 5.07368111264623 EC Unkn-01 TB_2140
1 A1 3.06982862746599 FT Unkn-09 TB_2140
1 A1 2.46545646544623 EC Unkn-01 TB_2140
为此,我尝试使用“-”作为分隔符的各种 awk 命令,但没有奏效。你知道怎么做吗?谢谢
awk 'BEGIN{FS=OFS="\t"}
NR==FNR {if (/^Plate Setup File Name/) {split($2,a,"-");id=a[2]};next}
{if (FNR==1) $6="Plate"; else $6=id} 1' A.txt B.txt > C.txt
这将扫描 中的一行“Plate Setup File Name” A.txt
,将值部分分隔为 上的字段-
,并存储“Plate”部分。处理时B.txt
,它会替换合适的标题条目或车牌 ID。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句