I am trying to use the file separator as "~" but somehow it is not working properly, where as other delimiter such as ",", "|" are working as expected. I mean there is no error but I am not getting desired output.
I am trying with the same data in "example.txt" file I have added 2 rows which are delimitd by ~, and then changed it to |.
Also main intention is to add the splitted name at the end of the record (interedsted only in newmodifiedline) rest i am just trying to test the values.
awk code :
awk 'BEGIN { FS = "~" } ; {line=$0}; {fullname=$1}; {split(fullname, a, " ")}; {arrysize=length(a)}; {newmodifiedline=line"~"a[1]"~"a[2];}; {print fullname, arrysize, a[1], a[2], "-->",newmodifiedline}' example.txt