Hi.,
nawk -F\| '{gsub("004","IND",$2)}1' p.txt
The above command is successfully replacing the code, but it is taking out the seperator away from the file.
It is resulting in :
av IND adkf Kent,004 s
av|005|ssdf|Kd,IT park|s
as opposed to my desired o/p:
av|IND|adkf|Kent,004|s
av|005|ssdf|Kd,IT park|s
Request you to provide the solution for this. And also as per my i/p file, is there any way to replace full file with all code list with all county list, by reading list i/p from a file?
Like in.,
my county_code.txt file
004,IND
005,SL
006,BNG
007,PAK
008,AFG
my i/p file:
av|004|adkf|Kent,004|s
av|005|ssdf|Kd,IT park|s
.
.
.
and my o/p should be of format:
av|IND|adkf|Kent,004|s
av|SL|ssdf|Kd,IT park|s
.
.
.
---------- Post updated at 04:10 AM ---------- Previous update was at 04:08 AM ----------
For the cmd.,
awk -F "|" '{OFS="|";gsub("004","IND",$2)}1' p.txt
It is again resulting in the following err:
a
wk: syntax error near line 1
awk: bailing out near line 1
Request you to give a work around for my more general problem, of replacing whole file at a stretch.
Thanks.,