Skip to main content
added 136 characters in body
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

This can be done with this,

$ sed -e 's/,/;/g' -e 's/;/,/1' infile test1,test2;test3 test4,test5 test6,test7;test8;test9;test10 test11,test12;test13;test14 

Explanation

  • s/,/;/g replaces all occurrence of , with ;

  • s/;/,/1 replaces the first occurrence of ; with ,


If you have GNU sed, you can also usetry this simple and handy,

sed 's/,/;/2g' infile 

This can be done with this,

$ sed -e 's/,/;/g' -e 's/;/,/1' infile test1,test2;test3 test4,test5 test6,test7;test8;test9;test10 test11,test12;test13;test14 

If you have GNU sed, you can also use,

sed 's/,/;/2g' infile 

This can be done with this,

$ sed -e 's/,/;/g' -e 's/;/,/1' infile test1,test2;test3 test4,test5 test6,test7;test8;test9;test10 test11,test12;test13;test14 

Explanation

  • s/,/;/g replaces all occurrence of , with ;

  • s/;/,/1 replaces the first occurrence of ; with ,


If you have GNU sed, you can also try this simple and handy,

sed 's/,/;/2g' infile 
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

This can be done with this,

$ sed -e 's/,/;/g' -e 's/;/,/1' infile test1,test2;test3 test4,test5 test6,test7;test8;test9;test10 test11,test12;test13;test14 

If you have GNU sed, you can also use,

sed 's/,/;/2g' infile