Hi,
I'm not sure, if this is a bug or I'm just losing it. The task: Display all empty lines in a file using grep.
Me, easy:
Why? Because there are no empty lines, there is always a newline character, without you got no empty line.
Correct answer:
Well, ok, according to the documentation '\n' (a.k.a newline) character is not treated as a real character, hence that is the correct answer.
So I tried this on 14.2-RELEASE-p2 using:
Not working! I checked several times that there are no space/tab character in that 'empty' line, nope no success.
How did I check ? I used vim and :
So I thought by myself perhaps I need to try this on linux, like Alma Linux 9.4:
And, it works !
Any help would be highly appreciated.
I'm not sure, if this is a bug or I'm just losing it. The task: Display all empty lines in a file using grep.
Me, easy:
grep -E '^[[:space:]]+$'

Why? Because there are no empty lines, there is always a newline character, without you got no empty line.
Correct answer:
grep '^$'
Well, ok, according to the documentation '\n' (a.k.a newline) character is not treated as a real character, hence that is the correct answer.
So I tried this on 14.2-RELEASE-p2 using:
$ /usr/bin/grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
$ pkg which /usr/local/bin/ggrep
/usr/local/bin/ggrep was installed by package gnugrep-3.12
Not working! I checked several times that there are no space/tab character in that 'empty' line, nope no success.

How did I check ? I used vim and :
grep -E '^[[:space:]]{1}$'
So I thought by myself perhaps I need to try this on linux, like Alma Linux 9.4:
$ rpm -qf /usr/bin/grep
grep-3.6-5.el9.x86_64
And, it works !

Any help would be highly appreciated.