[Solved] Replacing first occurrence of comma in unix shell script


sed is your friend. The result can be stored in a new file.

Give a try to this tested command below:

sed s/,/\',\'/ file.txt > result.txt

The sed man page contains information.

The test output:

$ cat input.txt
apple,orange,house 
foo,bar,woops
$ sed s/,/\',\'/ input.txt > result.txt
$ cat result.txt 
apple','orange,house
foo','bar,woops

solved Replacing first occurrence of comma in unix shell script