Shell – String replace

Previously we talked about how to submit a Google Form by the curl command.


In the url, we have to encode the special characters such as whitespace. In shell script, we could do string replace as follow.



Here is an example.


text="Hello World"

echo "${text}"
echo "${text// /%20}"


Check it out.

So now if you integrate the Google Forms submission in your backend, you could make sure the whitespace are all replaced by %20.

Done =)

Reference: nixCraft – Bash Script Replace Empty Spaces String


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.