Friday, 22 April 2016
How to trim spaces from a string variable ?
Example
var=" abc "
var="${var#"${var%%[![:space:]]*}"}"
# remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}"
# remove trailing whitespace characters
echo "===$var==="
No comments:
Post a Comment
Note: only a member of this blog may post a comment.
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.