Chinaunix首页 | 论坛 | 博客
  • 博客访问: 117003
  • 博文数量: 73
  • 博客积分: 66
  • 博客等级: 民兵
  • 技术积分: 497
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-22 14:59
文章分类

全部博文(73)

文章存档

2015年(65)

2013年(5)

2012年(3)

我的朋友

分类: LINUX

2015-01-30 14:05:38



grep "string" file_name
grep "string" file_name_* ---multiple files
grep -i "string" file_name  ---ignore sensitive case
grep -w "word" file_name ---search only word matched

grep -n "string" file_name --display the line

grep -A N "string" file_name -- search string and print N lines after matched lines
grep -B N "string" file_name -- search string and print N lines before matched lines

regular expression
grep "lines.*empty" demo_file
From documentation of grep: A regular expression may be followed by one of several repetition operators:
  • ? The preceding item is optional and matched at most once.
  • * The preceding item will be matched zero or more times.
  • + The preceding item will be matched one or more times.
  • {n} The preceding item is matched exactly n times.
  • {n,} The preceding item is matched n or more times.
  • {,m} The preceding item is matched at most m times.
  • {n,m} The preceding item is matched at least n times, but not more than m times
阅读(364) | 评论(0) | 转发(0) |
0

上一篇:tar

下一篇:find

给主人留下些什么吧!~~