Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Bash snippet - Trim leading and trailing whitespace from a variable.
SUBMITTED BY:
DanielK
DATE:
Aug. 13, 2016, 2:32 p.m.
FORMAT:
Bash
SIZE:
178 Bytes
Raw
Download
Tweet
HITS:
741
Go to comments
Report
# Usage: trim_whitespace some_var
trim_whitespace
()
{
local
trim_wh
local
to_trim
eval
to_trim
=
\$
$1
read
-rd
''
trim_wh
<<<
"
$to_trim
"
eval
$1
=
\$
trim_wh
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus