In the canonical How can I replace a string in a file(s)? in 3. Replace only if the string is found in a certain context, I'm trying to implement the replace of a pipe with white spaces in file with structure like this:
12/12/2000|23:16:03|Shell Sc|8332|START|TEXT|WITH|SPACES|-|[END]|[Something else]
I need it like this:
12/12/2000|23:16:03|Shell Sc|8332|START TEXT WITH SPACES -|[END]|[Something else]
The code:
echo "12/12/2000|23:16:03|Shell Sc|8332|START|TEXT|WITH|SPACES|-|[END]|[Something else]" | \
sed 's/\(START.*\)\|/ \1/g'
Any ideas ?