I have a 17 GB txt file and i cannot seem to load it via vim
. Researched on solutions provided here. However i do not seem to understand them very well and i am not good with linux or perl.
I understand i would have to use grep or something.
grep -oP "/^2" file
I have tried up to this code but i cannot seem to find the solution to output the number of occurences without printing all the lines to screen
I would like to find the number of lines that starts with a digit 2 in the file and output the number to shell.
Advertisement
Answer
If you want to continue using PCRE:
grep -cP ^2 file
Using grep’s “basic regular expressions”:
grep -c ^2 file