Fields in my file awk-test are enclosed in brackets and delimited with semicolon:
"col1";"col2";"col3";"col4";"col5";
"eiusmod";"tempor";"incididunt";"ut";"labore";
"et";"dolore";"magna";"aliqua";"Ut";
"enim";"ad";"minim";"veniam";"quis";
"ut";"aliquip";"ex";"ea";"commodo";
"nostrud";"exercitation";"ullamco";"laboris";"nisi";
Real data (header line plus three records):
"col1";"col2";"col3";"col4";"col5";
"/absence/lang/#LANG_ID#/.descr.php";"BP2_DESCR";"Dodaj";"Add";"Adicionar";
"/cal/lang/#LANG_ID#/cal_feed.php";"LF_COMM_MSG";"je komentiral ""#EVENT_TITLE#""";"commented on an event ""#EVENT_TITLE#""";"comentado sobre o evento ""#EVENT_TITLE#""";
"/mod/lang/#LANG_ID#/set_events.php";"IM_NOTIFY";"Pozdravljeni #USER_NAME#!
#FROM_USER# vam je poslal(a) sporocilo.
------------------------------------------
#FROM_USER#: #MESSAGE#
------------------------------------------;"Hello #USER_NAME#!
You have a new notification from #FROM_USER#
------------------------------------------
#MESSAGE#
------------------------------------------;"Olá #USER_NAME#!
Você tem uma nova notificação de #FROM_USER#
------------------------------------------
#MESSAGE#
------------------------------------------;
I know how to print first 30 lines of column 3 and 4 if column 3 has character "m":
gawk 'BEGIN {FS = ";" } ; $3 ~/m/ {print $3 ";" $4} NR==30{exit}' OFS=';' awk-test
The result is:
"magna";"aliqua"
"minim";"veniam"
"ullamco";"laboris"
But I don't know (a) how to replace "m" with "x" on a test 30 lines sample (b) how to replace "m" with "x" on a real 250.000 lines file.
Desired output on test-awk:
"xagna";"aliqua"
"xinim";"veniam"
"ullaxco";"laboris"
In reality I need to fix the errors on characters in column 3 only. Therefore I would like to know how to write the changed lines and keep the unchanged ones into a new file that will contain fixed column 3?
Thank you in advance!