My sample file has several lines like this
27809, shbd.dav, 165 .
27673 ; matroshka; 223665;
I need to count the lines containing digits. So the output should be 2.
I only have to use grep to do this.
My sample file has several lines like this
27809, shbd.dav, 165 .
27673 ; matroshka; 223665;
I need to count the lines containing digits. So the output should be 2.
I only have to use grep to do this.
Try this:
grep -c '[[:digit:]]' infile
replace [[:digit:]]
with [0123456789]
if you want restrict digits to only English digits (see Difference between [0-9]
, [[:digit:]]
and \d
).
[[:digit:]]
, and then the user can just setLC_ALL=C
if they need ASCII digits. – Kusalananda Apr 16 '21 at 11:36