Не обращайте внимания на переключатель регистра, и курсор не работает с grep, как ожидалось - PullRequest
0 голосов
/ 11 августа 2011

Учитывая следующий файл:

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

следующие 2 команды работают так, как я ожидал:

grep -i '[:alpha:]' testfile

дает

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

Каретка, которая должна гарантировать, что строка начинается с буквенно-цифровой последовательности, испортила всевверх.Почему строка «это несколько слов» и строка «Начать с заглавных букв» не совпадают?Это использует bash на Mac Lion.

1 Ответ

0 голосов
/ 11 августа 2011

Я считаю, что вы ищете:

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