Because of the way the app was written I have some odd limitations. So I realize there are easier ways to do what I want, but I kind of need to make this work.
So I have a files text that is moving though a pipe. So, I want to replace all of the spaces with a ‘+’ after a point in the string. I have to do it in the pipe, and move it to the next command. So multiple commands are a no go.
What I was trying:
Code:
echo "URL: http://www.google.com/hello world 1 2 3" | sed 's/http:\(.*\) /\1+/'
But it only replaces it once:
Code:
URL: //www.google.com/hello world 1 2+3
I though, “Ok, so I will just run it though the same command.
Code:
echo "URL: http://www.google.com/hello world 1 2 3" | sed 's/http:\(.*\) /\1+/' | sed 's/http:\(.*\) /\1+/'
No change:
Code:
URL: //www.google.com/hello world 1 2+3
Scratched my head for a sec, then did this:
Code:
echo "URL: http://www.google.com/hello world 1 2 3" | sed 's/http:\(.*\) /\1+/' | sed 's/ttp:\(.*\) /\1+/'
And got:
Code:
URL: //www.google.com/hello world 1+2+3
Why can’t you do multiple ?stages? in the pip with sed? Am I missing something?
Same for:
Code:
echo "URL: http://www.google.com/hello world 1 2 3" | sed 's/http:\(.*\) /\1+/' | sed 's/ttp:\(.*\) /\1+/' | sed 's/http:\(.*\) /\1+/'