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
Dealing with Funny Files
Viewed 3648 times since Wed, May 30, 2018
HowTo: Clear BASH History
Viewed 2991 times since Mon, Feb 18, 2019
Convert a human readable date to epoch with a shell script on OpenBSD and Mac OS X
Viewed 16252 times since Fri, May 25, 2018
10 Awk Tips, Tricks and Pitfalls
Viewed 6918 times since Wed, Aug 19, 2020
awk printf
Viewed 17454 times since Wed, Aug 19, 2020
Display basic information about Physical Volumes
Viewed 4530 times since Sun, Jun 3, 2018
8 Practical Examples of Linux Xargs Command for Beginners
Viewed 6825 times since Fri, Jun 1, 2018
O’Reilly’s CD bookshelf
Viewed 15719 times since Wed, Jun 27, 2018
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 6471 times since Thu, Feb 11, 2021
Utilities to Tidy Up Your Reports
Viewed 17193 times since Wed, May 30, 2018