Пробовал с помощью приведенной ниже команды и работал нормально
команда
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
Попробуйте:
awk -F' = ' 'NR==3{a=$2} {if(NR<14)print; else print a $0}' A.txt
Использование вашего образца ввода:
$ awk -F' = ' 'NR==3{a=$2} {if(NR<14)print; else print a $0}' A.txt
kit
Software Version =
Date And Time of Export = 07/02/2020 13:44:11 UTC
Experiment Name =
Instrument Software Version =
Instrument Type = CFX
Instrument Serial Number =
Run Start Date =
Run End Date =
Run Operator =
Batch Status = VALID
Method = Novaprime
Date And Time of Export,Batch ID,Sample Name,Well,Sample Type,Status,Interpretive Result,Action*,Curve analysis
07/02/2020 13:44:11 UTC,taq,205920777.1,A01,Unkn-01
07/02/2020 13:44:11 UTC,taq,neg5,A02,Unkn-09
Для тех, кто предпочитает, чтобы их команды располагались на нескольких строках:
awk -F' = ' '
NR==3{
a=$2
}
{
if(NR<14)
print
else
print a $0
}
' A.txt
-F' = '
Это устанавливает разделитель полей на =
.
NR==3{a=$2}
Для строки номер три это сохраняет второе поле в переменной a
.
if(NR<14)print; else print a $0
Если номер строки меньше 14, строка печатается без изменений. Для остальных строк печатается строка с переменной a
перед ней.
awk -F' = ' 'NR==3{t=$2} NR<14{print;next} NR>17{print t d} {d=c;c=b;b=a;a=$0} END{print d ORS c ORS b ORS a}' A.txt
Пример входного файла:
$ cat A.txt
kit
Software Version =
Date And Time of Export = 07/02/2020 13:44:11 UTC
Experiment Name =
Instrument Software Version =
Instrument Type = CFX
Instrument Serial Number =
Run Start Date =
Run End Date =
Run Operator =
Batch Status = VALID
Method = Novaprime
Date And Time of Export,Batch ID,Sample Name,Well,Sample Type,Status,Interpretive Result,Action*,Curve analysis
,taq,205920777.1,A01,Unkn-01
,taq,neg5,A02,Unkn-09
end1
end2
end3
end4
Соответствующий выход:
$ awk -F' = ' 'NR==3{t=$2} NR<14{print;next} NR>17{print t d} {d=c;c=b;b=a;a=$0} END{print d ORS c ORS b ORS a}' A.txt
kit
Software Version =
Date And Time of Export = 07/02/2020 13:44:11 UTC
Experiment Name =
Instrument Software Version =
Instrument Type = CFX
Instrument Serial Number =
Run Start Date =
Run End Date =
Run Operator =
Batch Status = VALID
Method = Novaprime
Date And Time of Export,Batch ID,Sample Name,Well,Sample Type,Status,Interpretive Result,Action*,Curve analysis
07/02/2020 13:44:11 UTC,taq,205920777.1,A01,Unkn-01
07/02/2020 13:44:11 UTC,taq,neg5,A02,Unkn-09
end1
end2
end3
end4
Версия, не зависящая от линии
awk -F, -v OFS="," '$0~/UTC/{split($0,ar,"= ")}$2=="taq"{$1=ar[2]}1' file
kit
Software Version =
Date And Time of Export = 07/02/2020 13:44:11 UTC
Experiment Name =
Instrument Software Version =
Instrument Type = CFX
Instrument Serial Number =
Run Start Date =
Run End Date =
Run Operator =
Batch Status = VALID
Method = Novaprime
Date And Time of Export,Batch ID,Sample Name,Well,Sample Type,Status,Interpretive Result,Action*,Curve analysis
07/02/2020 13:44:11 UTC,taq,205920777.1,A01,Unkn-01
07/02/2020 13:44:11 UTC,taq,neg5,A02,Unkn-09
,,,,,,,,,,
*reporting.
Установите для FS
и OFS
значение ,
, но разделите дату на массив ar
в строке, где вы найдете UTC
, а затем просто вставьте как $1
везде, где$2=="taq"