I want to filter a file for lines starting with a space. I use the following command:
grep -v "^ " < input > input_no_starting_space
To double check my results, I run the following:
grep "^ " < input > double_check
and then count the number of lines in
double_check to see whether their sum adds up to the number of lines in
input. For this I use
For some reason, this check fails. Meaning, the sum of the number of lines is less than the number of lines in
input. My file has millions of lines, but I cannot seem to reproduce the issue on a small example. Is there by any chance something wrong with the way I use grep (since I would expect that
grep -v always give the complement of one another), or is this more likely an artifact in my file? In case of the latter, what could this artifact be?
This is using GNU grep 3.4 on Ubuntu 20.04.3.