Hitul Mistry Hitul Mistry - 5 months ago 10
Bash Question

How to remove space from string?

In ubuntu bash script how to remove space from one variable

string will be

3918912k


Want to remove all blank space.

Answer

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