我有一笔复杂的交易csv。我需要提取从包含字符串"Transaktion“的特定行/字段开始的数据,并跳过csv的最后一行。
我可以让AWK找到起跑线和处理,然后所有以下。这很好,但我不能添加跳过最后一行的方法。
/^Transaktionen/,/^$/ {
getline;
print $2 FS $3 FS $4}
发布于 2017-03-22 09:55:14
您可以使用这个awk
awk '/^Transaktionen/{p=1; next} p {
if (c2 != "") print c2, c3, c4; c2=$2; c3=$3; c4=$4}' file.csv
试试这个awk脚本:
BEGIN {
#OFS=FS=";" ;
#print $0;
print "Datum2;Zahlart3;TXN Kundendetails4 - KundenID5;Beschreibung6;Betrag7;Gebuehr10;Disagio11;Auszahlungsbetrag12";
#einnahmen = "Transaktionen";
#erstattung = "Refunds";
}
/^Transaktionen/{p=1; next} p {
if (c2 != "")
print c2, c3, c4, c5, c6 , c7 ,c10, c11, c12;
c2=$2; c3=$3; c4=$4; c5=$5; c6=$6; c7=$7; c10=$10; c11=$11; c12=$12;
}
https://stackoverflow.com/questions/42959011
复制