Ok, since this is a complex question, I will explain it clearly. I got a file content shown as below:
$ Cat File1
ABC Cool Lol POP {MNB}
ABC Cool Lol POP {MNB}
ABC Cool Lol POP {MNB}
ABC Cool Lol POP {TBMKF}
ABC Cool Lol POP {YUKER}
ABC Cool Lol POP {EFEFVD}
The output that I want
-Cool MNB + POP ;
-Cool MNB + POP ;
-Cool MNB + POP ;
-Cool TBMKF + POP ;
-Cool YUKER + POP ;
-Cool EFEFVD +POP ;
Firstly I try to take out the last column from the File1
and print it out by
sed 's/[{}//g' File1 > File3
After that I copy the whole content of File1
to a new File4
cp File1 File4
After that I replace the data inside the File4
with the File3
data (means the data without bracket one "File1
last column that one")
awk 'FNR==NR{a[NR]=$1;next}{$5=a[FNR]}1' File3 File4 >>File5
Output should be like this
ABC Cool Lol POP MNB
ABC Cool Lol POP MNB
ABC Cool Lol POP MNB
ABC Cool Lol POP TBMKF
ABC Cool Lol POP YUKER
ABC Cool Lol POP EFEFVD
Finally, I try
awk -F“ " '{print - $2,$5 +,$4 ";"}‘ File5
But the outcome did not come out as shown as I want, only the similar data MNB is all listed down, others did not shown up (File one last column data),
awk --version
, whats the result?