grep 命令使用指南
grep 命令
grep参数:
-E:等同于egrep
-o:只匹配你想要的内容,下面是示例:
[root@localhost ~]# cat /data/game/config/server_config.txt | grep mysql_port | egrep -o "[0-9]+"
3306
[root@localhost ~]# cat /data/game/config/server_config.txt | grep mysql_port | egrep "[0-9]+"
{mysql_port, 3306}.
使用grep命令进行多个条件查询:
[root@TX- tmp]# cat a.txt
error
error
error
error
error
ERROR
ERROR
ERROR
ERROR
ERROR
ERROR
ERROR
[root@TX- tmp]# cat a.txt | grep -E "error|ERROR"
error
error
error
error
error
ERROR
ERROR
ERROR
ERROR
ERROR
ERROR
ERROR
[root@TX- tmp]#
使用grep匹配ip地址:
[root@localhost ~]# egrep "[0-9]+.[0-9]+.[0-9]+.[0-9]+." a
123.123.123.123
123.123.
[root@localhost ~]# egrep "[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}." a
123.123.123.123
123.123.
grep 命令使用指南的更多相关文章
- Git命令使用指南
继续git相关的东西,网上很多讲解的,但是还是喜欢这个图:(爱屋及乌,当然内容也很好,文章链接:http://me.iblogc.com/2015/01/16/Git命令使用指南/) Git是软件开发 ...
- linux grep命令
linux grep命令1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressio ...
- grep 命令
简单介绍:grep命令是用于分析一行信息,若当中有我们所需要的信息,就将该行取出来. 语法结构:grep [-acinv] [--color=auto] '查找关键字' #{filename} -a: ...
- linux管道命令grep命令参数及用法详解---附使用案例|grep
功能说明:查找文件里符合条件的字符串. 语 法:grep [-abcEFGhHilLnqrsvVwxy][-A<显示列数>][-B<显示列数>][-C<显示列数>] ...
- grep 命令详解
[root@www ~]# grep [-acinv] [--color=auto] '搜寻字符串' filename 选项与参数: -a :将 binary 文件以 text 文件的方式搜寻数据 - ...
- grep 命令操作
linux grep命令 1.作用Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expressi ...
- Linux命令(23)grep命令的使用
grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正 ...
- 每天一个linux命令(39):grep 命令
Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...
- grep命令的使用
grep是UNIX和LINUX中使用最广泛的命令之一.grep允许对文本文件进行模式查找.如果找到匹配模式, grep打印包含模式的所有行.grep支持基本正则表达式,也支持其扩展集.grep有三种变 ...
随机推荐
- 牛的障碍Cow Steeplechase
题目描述 Farmer John has a brilliant idea for the next great spectator sport: Cow Steeplechase! As every ...
- 单网卡安装neutron
devstack中机器只有一个物理网卡,如何设置neutron中的external网络? 方式是: 创建一个linux bridge和veth,把eth0和veth1加入到brige,用veth的另一 ...
- html笔记(1)
hgroup 代替div figure figcaption 独立流内容 替代 dl mark 替代 span
- eclipse中修改工程的Android版本
项目根目录下project.properties的记录项目中所需要的环境信息,比如Android的版本等 project.properties示例如下: [html] view plaincopy # ...
- MYSQL变量和状态
mysql设置变量是在my.cnf文件里,修改配置文件后需要重启mysql的服务,才能生效.但是在线上服务器是不允许随便重启的,我们可以用命令直接修改变量值,使其生效.然后再修改配置文件中的值,以防止 ...
- 慕课网:4-2—— 使用DB facade实现CURD (09:11)
public function test1() { //新增数据: /* $bool=DB::insert('insert into student(name,age) VALUES (?,?)', ...
- 漂亮的Html5网站
http://www.mrdoob.com/projects/chromeexperiments/ball-pool/
- LeetCode OJ:Two Sum(两数之和)
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- Django -- DRF 认证流程
Django Restful Framework (DRF)中类的调用与自定义-- 以 autentication 认证为例 DRF 的 request 对 django 的 request 进行了更 ...
- Android中从SD卡中读取歌曲
先看看我的效果图吧 Activity类 private TextView nameTextView; private SeekBar seekBar; private ListView listVie ...