1

Replace first space with other string in file with Bash script

view story
linux-howto

http://stackoverflow.com – for example I have a string like "test test test " in a file. I want to replace the first space with ' 1 ' to make it "test 1 test test test " . I tried sed -i "s/^\ /\ 1\ /g" text.txt but it will change all spaces to ' 1 ', so I would like to know how to make it only happen on the first found? (HowTos)