Hitul Mistry Hitul Mistry - 1 year ago 104
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download