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
Table of contents 1. Usage of keep-alive Example ...
How to define complex components (class component...
It took me three hours to install MySQL myself. E...
I. Introduction First, let me explain the version...
In MySQL, you can use the REVOKE statement to rem...
<br />Tips for making web table frames. ----...
1. Create a database: create data data _name; Two...
This article uses an example to describe how to c...
First, you need to determine which fields or fiel...
1. Color matching effect preview As shown in the ...
What Beautiful HTML Code Looks Like How to write ...
<p><b>This is bold font</b></...
Environmental Statement Host OS: Cetnos7.9 Minimu...
This article describes the Linux user and group c...
1. Download docker online yum install -y epel-rel...