OSX Services - character substitution + for _ I've created a service to use primarily in a browser for searching IMDB, so instead of copying and pasting the film's name I just select the text and run the service I created which will automatically search IMDB for the selected text. This works perfect.



I was hoping to do the same for Wikipedia and so i've been trying to modify the same service but have come across a problem. The search query places a "+" between each word.

This doesn't work for Wikipedia. They place underscores between their words.



I wondered how I can substitute the + for _?
This is what I currently have

open "https://en.wikipedia.org/wiki/$(ruby -rcgi -e 'print CGI.escape $&lt;.read.chomp')"


Kinds regards and Merry Christmas :)
open "https://en.wikipedia.org/wiki/$(ruby -rcgi -e 'print CGI.escape $&lt;.read.chomp' | sed 's/+/_/g')"


sed 's/+/_/g' replaces all instances of + with _