Вопрос

I have a text file that stores combinations of four numbers in the following format:

Num1,Num2,Num3,Num4
Num5,Num6,Num7,Num8
.............

I have a whole bunch of such files and what I need is to grep for all filenames that contains the pattern described above.

I constructed my grep as follows:

grep -l "{d+},{d+},{d+},{d+}" /some/path/to/file/name

The grep terminates without returning anything.

Can somebody point out what I might be doing wrong with my grep statement?

Thanks

Это было полезно?

Решение

This should do what you want:

egrep -l '[[:digit:]]+,[[:digit:]]+,[[:digit:]]+,[[:digit:]]+' /some/path/to/file/name

Другие советы

One way is using a perl regexp:

grep -Pl "\d+,\d+,\d+,\d+" /some/path/to/file/name

In your syntax d is literal. It should be escaping that letter, but is not accepted by grep regular regexp.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top