Command-line Knowledge Base
Replace spaces in a string with underscores without using sed
or tr
$ str="This is just a test" $ echo ${str// /_} This_is_just_a_test
sed
or tr
$ str="This is just a test" $ echo ${str// /_} This_is_just_a_test