There are many methods on the Internet that, although correct, do not produce correct results when used. Here is the correct method. Remove leading spaces $text=" 123 456 " # This way of writing ensures the correct result. text=`echo $text | sed -e 's/^[ \t]*//g'` # These methods are not tested, please refer to the above for writing. # Remove trailing spaces sed 's/[ \t]*$//g' # Delete leading and trailing spaces, but not spaces in between sed -e 's/^[ \t]*//g' -e 's/[ \t]*$//g' # Remove all spaces in a string sed 's/[[:space:]]//g' Of course there is an easy way: # Replace only one text=${text/ /-} # Replace all text=${text// /-} Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: MySQL slow query log configuration and usage tutorial
>>: In-depth understanding of the implementation principle of require loader
This article shares the specific code of js to re...
1. Conclusion Syntax: limit offset, rows Conclusi...
The configuration method of MySQL 5.5.56 free ins...
Preface Recently I started using robot framework ...
Important data must be backed up, and must be bac...
1. Connect Centos7 under VMware and set a fixed I...
Table of contents Step 1: Update Packages on Cent...
How long has it been since I updated my column? H...
1. Key points for early planning of VMware vSpher...
HTML-centric front-end development is almost what ...
When applying docker containers, we often mount t...
Preface In order to follow the conventional WEB l...
Pop-up windows are often used in actual developme...
Deployment environment: docker container, liunx s...
After learning the basic operations of Docker, we...