On Fri, Jan 19, 2024 at 07:10:51AM +0000, [email protected] wrote: > why doesn't grep count 2 commas > > > echo 'Kích thước máy xay cỏ, giá máy thế nào , phụ tùng máy mua ở đâu' | grep > -c , > 1 > > echo 'Kích thước máy xay cỏ, giá máy thế nào , phụ tùng máy mua ở đâu' | cut > -d, -f1 > Kích thước máy xay cỏ > > echo 'Kích thước máy xay cỏ, giá máy thế nào , phụ tùng máy mua ở đâu' | cut > -d, -f2 > giá máy thế nào > > echo 'Kích thước máy xay cỏ, giá máy thế nào , phụ tùng máy mua ở đâu' | cut > -d, -f3 > phụ tùng máy mua ở đâu
It is in the man page:
-c, --count
Suppress normal output; instead print a count of matching lines
for each input file. With the -v, --invert-match option (see
below), count non-matching lines.
It counts matching lines. You gave it one line.
If you want to go character-wise, tr might fit the bill (e.g. do a tr -c
to remove everything except comma, then measure the resulting string's
length).
Of course, if you have something else than shell+utils there might be
more efficient ways.
Cheers
--
t
signature.asc
Description: PGP signature

