bash下面grep匹配tab及相关模式的用法

linux bash man page里面提到:

ANSI-C Quoting

Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specifed by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows:

\a
alert (bell)
\b
backspace
\e
an escape character (not ANSI C)
\f
form feed
\n
newline
\r
carriage return
\t
horizontal tab
\v
vertical tab
\\
backslash
\'
single quote
\nnn
the character whose ASCII code is the octal value nnn (one to three digits)
\xnnn
the character whose ASCII code is the hexadecimal value nnn (one to three digits)

The expanded result is single-quoted, as if the dollar sign had not been present.

也就是说如果你想在source.txt里面grep匹配tab+targetword内容,那么写法应该是:

grep $'\t'targetword  source.txt.

posted on 2011-11-29 15:32 ewre 阅读(280) 评论(0)  编辑 收藏 引用 所属分类: Scripting language


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(2)

文章分类

文章档案

最新评论

阅读排行榜