I am working with a long file called test that looks as follows:
AHAP USA|NIS00333|+NULL|NISGOOGLE|NIS00005|*binary|NISCAR
KJJLIL123124%|NIS00160|+NULL|NISFACEBOOK|NIS00006|*binary|NISBUR
ASFASS9992|NIS00164|+NULL|NISTABLE|NIS00008|*binary|NISFANCY
I need to make a replacement the string "NIS" to "NIX", however I need to achieve this only in the second column that is delimited by the pipe character, the separator of my data is the pipe "|", and I have several columns, seven in total, I just want to do the replacement in the second one.
I tried:
$ sed s/NIS/NIX/g test
AHAP USA|NIX00333|+NULL|NIXGOOGLE|NIX00005|*binary|NIXCAR
KJJLIL123124%|NIX00160|+NULL|NIXFACEBOOK|NIX00006|*binary|NIXBUR
ASFASS9992|NIX00164|+NULL|NIXTABLE|NIX00008|*binary|NIXFANCY
But it is affecting all the columns that match with the string: NIS and change it to NIX, I just want to affect the second column, my desired output would be:
AHAP USA|NIX00333|+NULL|NISGOOGLE|NIS00005|*binary|NISCAR
KJJLIL123124%|NIX00160|+NULL|NISFACEBOOK|NIS00006|*binary|NISBUR
ASFASS9992|NIX00164|+NULL|NISTABLE|NIS00008|*binary|NISFANCY
I really appreciate help with this issue, thanks any how.