Last active
August 29, 2015 14:05
-
-
Save honwhy/d7aecec03c3e22012f64 to your computer and use it in GitHub Desktop.
use regular expression in sed command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 在Linux终端使用sed命令,使用正则表达式时+没有被当作元字符 | |
| # 1. 使用如下命令 | |
| sed -i '/^[0-9]+/d' some.txt | |
| cat some.txt | |
| # 并不能够将数字开头的行删除 | |
| # 2. 使用如下命令 | |
| sed -i '/^[0-9]\+/d' some.txt | |
| #就可以满足刚才的需求了 | |
| cat some.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考 sed metacharacters文档
http://www.cuyamaca.net/gainswor/schedule_532_files/SED_metacharacters.pdf
这里并没有发现+的写法,但是又{m,n}量词写法,都需要\转义。