Substituting the first occurrence of a pattern in a line, for all the lines in a file with sed
You're overthinking it. sed
replaces only the first instance on a line by default (without the /g
modifier), although you still want to anchor because you don;t so much want the first instance in the line as the one at the start of the line; and you usually don't need the explicit line actions you're trying to use (why?).
sed 's/^" /"/'
A more general answer, since I can't comment on geekosaur's answer - You wouldn't put the ^ (start of line anchor). For example, if you want to replace the first occurence of A with B, you would have
sed 's/A/B/'