忽略大小写开关和插入符号未按预期使用grep

忽略大小写开关和插入符号未按预期使用grep,grep,osx-lion,Grep,Osx Lion,给定以下文件: this is some words and this one too<div> <html></html> and more words 123 Caps to begin ASDFSDFSDF 给予 给予 但是 及 应该确保行以字母数字开头的插入符号把一切都搞糟了。为什么“this is some words”行和“Caps to begin”行不匹配? 这是在Mac Lion上使用bash。我相信您需要的是: grep '^[[:alp

给定以下文件:

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

给予

但是

应该确保行以字母数字开头的插入符号把一切都搞糟了。为什么“this is some words”行和“Caps to begin”行不匹配?
这是在Mac Lion上使用bash。

我相信您需要的是:

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

啊,对。我把语法“[:alpha:][]”和“[a-z]”搞混了。Grep和疲倦不能很好地结合。。
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
ASDFSDFSDF
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
grep '^[[:alpha:]]' testfile
grep -i '^[[:alpha:]]' testfile