Usuwanie spacji z zmiennych w bash

Usuwanie początkowych / „wiodących” spacji z zmiennej:

ZMIENNA="${ZMIENNA#"${ZMIENNA%%[![:space:]]*}"}"

Usuwanie końcowych / „wleczących” spacji z zmiennej:

ZMIENNA="${ZMIENNA%"${ZMIENNA##*[![:space:]]}"}"
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
The Ultimate Bash Array Tutorial with 15 Examples
Viewed 14166 times since Sun, Sep 30, 2018
Adding a range of IPs in Linux
Viewed 3168 times since Mon, May 21, 2018
How to sort IP addresses in Linux
Viewed 4443 times since Thu, May 24, 2018
Script HW/SW AIX
Viewed 9927 times since Mon, Jun 4, 2018
Bash: Read File Line By Line – While Read Line Loop
Viewed 2841 times since Mon, Feb 18, 2019
O’Reilly’s CD bookshelf
Viewed 14396 times since Wed, Jun 27, 2018
Utilities to Tidy Up Your Reports
Viewed 16669 times since Wed, May 30, 2018
Dealing with Funny Files
Viewed 3251 times since Wed, May 30, 2018
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 5747 times since Thu, Feb 11, 2021
How to get a password from a shell script without echoing - solutions
Viewed 14825 times since Fri, Feb 22, 2019