grep empty lines in a file 1

grep empty lines in a file

grep -c '^$' myfile.txt

Here is what the above code is Doing:
1. The -c option tells grep to count the number of lines that match the pattern.
2. The ^$ pattern matches lines that contain nothing but the newline character.
3. The -v option tells grep to invert the match, so that it prints lines that do not match the pattern.
4. The -c option tells grep to count the number of lines that match the pattern.
5. The ^$ pattern matches lines that contain nothing but the newline character.

Similar Posts