0

I have a .csv (utf-8 text file). It has millions of lines. I can count the lines with wc -l. I want to count only lines with specific characters in them. So if 2M of 10M lines had a "1" in them, I'd like to return 2M.

Is this possible? Will this be horrendously slow? What are some ways to do this?

T. Brian Jones
  • 13,002
  • 25
  • 78
  • 117

1 Answers1

2

This writes all lines from file.csv with a "1" to stdout:

grep "1" file.csv

With a pipe you can connect stdout (of grep) and stdin (of wc):

grep "1" file.csv | wc -l
Cyrus
  • 84,225
  • 14
  • 89
  • 153