忽略大小写开关和插入符号无法按预期与 grep 配合使用
给定以下文件:
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
ASDFSDFSDF
以下 2 个命令按我的预期工作:
grep -i '[:alpha:]' testfile
Gives
this is some words
and this one too<div>
<html></html>
and more words 123
Caps to begin
ASDFSDFSDF
和
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
和
grep -i '^[:alpha:]' testfile
and this one too<div>
and more words 123
ASDFSDFSDF
插入符号应确保该行以字母数字开头,但已经把一切搞乱了。为什么“这是一些单词”行和“大写开头”行不匹配? 这是在 Mac Lion 上使用 bash。
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
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您正在寻找的是:
I believe what you're looking for is: