echo " lfj"|sed -e "s/^\s+//g"
lfj
I remember +
indicates one or more
, so there's two white spaces in front of lfj
, why cannot it strip them?
You need to escape the +
.
$ echo " lfj"|sed -e "s/^\s\+//g"
lfj
Basic sed uses BRE(Basic REgular Expressions). To make +
to repeat the previous character one or more times in BRE, you need to escape it.
Enable the extended regexp option -r
in sed to make sed to use ERE instead of BRE.
$ echo " lfj"|sed -r "s/^\s+//g"
lfj
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments