I have the following content in a file.
$ cat file.txt
path,foo,12344,bar,foo,example4/path/1,test2
path,bar,12345,bar,bar,example2/path/4,test5
I would like to change the "path" on the 6th field to "test-path".
path,foo,12344,bar,foo,example4/test-path/1,test2
path,bar,12345,bar,bar,example2/test-path/4,test5
I tried with following, but it didn't work.
$ awk -F, -v needle='path' -v replacement='test-path' 'BEGIN{ OFS = FS; } (NR > 1 && $6 == needle) { $6 = replacement; } 1' file.txt