I have a file with three fields and field delimiter '|' like:
abc|12:13:45|123
xyz|12:87:32|
qwe|54:21:09
In the file the 1st line has proper data -> abc|12:13:45|123
,the 2nd line doesnt has data for the 3rd field which is okay
, the 3rd line doesnt has data for the 3rd field as well the field delimiter before the 3rd field is also missing.
I have the requirement to add the field delimiter for the last field if the last field as well as the field delimiter is missing as with the case of the 3rd line:
the 3rd line should look like:
$ awk -F"|" '{NF=3}1' OFS="|" file
awk: syntax error near line 1
awk: bailing out near line 1
$ awk -F\| 'NF == 2 { $0=$0 FS} 1' file
awk: syntax error near line 1
awk: bailing out near line 1