tags:

views:

64

answers:

2

I know I can translate upper to lower case letters by

echo 'linux' | tr "a-z" "A-Z"

who would I translate or replace an occurrence of & with %20%26%20. Maybe something like this

echo '&' | tr "&" "%20%26%20"
A: 
sed -i 's/&/%20%26%20/g' inputfile

will edit the file in place.

Dennis Williamson
You forgot -i and s?
Anders
hfranco
@hfranco: On my system, the ampersand doesn't need to be escaped on the left side.
Dennis Williamson
@hfranco. Yeah, mine is fine also.
Anders
A: 

you can just use the shell.

$ var="&test"
$ echo ${var//&/%20%26%20}
%20%26%20test
ghostdog74