Skip to content
Advertisement

Change some field separators in awk

I have a input file 1.txt

JavaScript

and I want an output file: out.txt

JavaScript

I want to replace the first two ‘:’ in 1.txt with ‘||o||’, but with the script I am using

JavaScript

But it is not giving the expected output. Any help would be highly appreciated.

Advertisement

Answer

Following sed may also help you in same.

JavaScript

Explanation: Simply substituting 1st occurrence of colon with ||o|| and then 2nd occurrence of colon now becomes 1st occurrence of colon now and substituting that colon with ||o|| as per OP’s requirement.

Advertisement