The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: Replace spaces
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-06-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by tret View Post
Hi guys, so I have another issue. Can I use sed to replace spaces in a string or variable with %20

I am having trouble with using curl on URL's containing spaces

Code:
string=$( printf "%s\n" "$string" | sed 's/ /%20/g' )
Or. with bash or ksh93:

Code:
string=${string// /%20}