replace nth occurence of string in each line of a text file
- by dnkb
I have large text files with space delimited strings (2-5). The strings can contain "'" or "-". I'd like to replace say the second space with a pipe. What's the best way to go?
Using sed I was thinking of this:
sed -r 's/(^[a-z'-]+ [a-z'-]+\b) /\1|/' filename.txt
Any other/better/simpler ideas?
Thank you