Hitul Mistry Hitul Mistry - 10 months ago 36
Bash Question

How to remove space from string?

In ubuntu bash script how to remove space from one variable

string will be


Want to remove all blank space.


Try doing this in a shell:

s="  3918912k"
echo ${s//[[:blank:]]/}

That uses parameter expansion

[[:blank:]] is a POSIX regex class (remove spaces, tabs...), see http://www.regular-expressions.info/posixbrackets.html