Bash Find and Replace in a String

The following command replaces existing white space with the character "_" in the variable $var1 and assigns it to the variable $var2.

$var2=$(echo "$var1" | sed 's/ /_/g');

No comments:

Post a Comment