Hi there,
I have a comma seperated file and an other file I use as filter. I have also this awk
awk -F',' 'NR==FNR{_[$1];next} $3 in _{print}' mcities.txt Offices.csv
but instead of printing me the values that exist in the filter, I want in my Offices.csv file to add ',-' at the end of the file.
Can somebody help?
Thanks
Maybe I'm missing something but if you want to add ',-' to the end of the file Offices.csv:
echo ',-' >> Offices.csv
Regards
I want to add it if the value of the 3rd field exists in the filter (mcities.txt)
awk -F',' 'NR==FNR{_[$1];next} $3 in _{$0=$0",-"}1' filter file
Maybe I'm missing something, but if you want to add it at the end of the file:
awk -F',' 'NR==FNR{_[$1];next} $3 in _{exit}END{system "echo ,- >> Offices.csv"}' mcities.txt Offices.csv
This is what I was meaning.
Thanks a lot for your help!
That means at the end of the line instead of at the end of the file.
Regards
You are correct. My mistake. Thanks for your help