shell, +, *, [: space:] Usage

http://blog.itpub.net/27181165/viewspace-1061688/

In linux often used in conjunction with a regular expression to shell filter character, a simple example will be used herein to illustrate +, *, [: space: ] Some Usage
+ characters matching one or more
* zero or more matches characters
[: space:] matches whitespace characters, including spaces, tab
file is the file contains more than a few lines of spaces and tab characters, the following documents will file an example to do a few simple experiments
[root @ node1 ~] # cat File
     . 5
 . 5
   . 5
. 5
            . 5
              . 5
remove the space
[root @ node1 ~] # sed ' S / G * //' File
. 5
. 5
. 5
. 5
    . 5
    . 5
[the root @ node1 ~] #
delete space
[root @ node1 ~] # sed ' S / + // G 'File
     . 5
 . 5
   . 5
. 5
            . 5
              . 5
[the root @ node1 ~] #
is not working
[the root @ node1 ~] # Sed' S / \ + // G 'File
. 5
. 5
. 5
. 5
    . 5
    . 5
[the root @ node1 ~] #
+ escape spaces may be deleted after
[the root @ node1 ~] # Sed 'S / [[: Space:]] // G' File
. 5
. 5
. 5
. 5
. 5
. 5
[the root @ node1 ~] #
delete all whitespace characters, including tab

Guess you like

Origin www.cnblogs.com/sinferwu/p/12028530.html