Given the following file:
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
ASDFSDFSDF
the following 2 commands work as I would expect:
grep -i '[:alpha:]' testfile
gives
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
ASDFSDFSDF
and
开发者_JAVA百科grep '[:alpha:]' testfile
gives
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
but
grep '^[:alpha:]' testfile
and this one too<div>
and more words 123
and
grep -i '^[:alpha:]' testfile
and this one too<div>
and more words 123
ASDFSDFSDF
The caret which should ensure the line begins with an alphanumeric has messed everything up. Why is the 'this is some words' line and the 'Caps to begin' line not getting matched? This is using bash on Mac Lion.
I believe what you're looking for is:
grep '^[[:alpha:]]' testfile
grep -i '^[[:alpha:]]' testfile
精彩评论