2011-08-10 26 views
0

鑑於以下文件grep的工作:忽略大小寫切換和尖不與預期

this is some words 
and this one too<div> 
<html></html> 
and more words 123 
Caps to begin 
ASDFSDFSDF 

以下兩個命令工作,我期望:

grep -i '[:alpha:]' testfile 

this is some words 
and this one too<div> 
<html></html> 
and more words 123 
Caps to begin 
ASDFSDFSDF 

and

grep '[:alpha:]' testfile 

this is some words 
and this one too<div> 
<html></html> 
and more words 123 
Caps to begin 

grep '^[:alpha:]' testfile 

and this one too<div> 
and more words 123 

grep -i '^[:alpha:]' testfile 

and this one too<div> 
and more words 123 
ASDFSDFSDF 

應確保線路開始以字母數字已經一切都搞砸了插入符號。爲什麼'這是一些字'的行和'帽開始'行不匹配? 這是在Mac Lion上使用bash。

回答

0

我相信你要找的是什麼:

grep '^[[:alpha:]]' testfile 
grep -i '^[[:alpha:]]' testfile 
+0

是啊。我混淆了語法'[[:alpha:]]'和''[a-z]''。 Grep和疲倦混合不好 – Brynjar