grep "^$" filename.txt
No of empty lines in a file
grep "^$" filen| wc -l
or
grep -c "^$" a.sh
or AWK
awk '{
if (NF == 0)
{
# print "Here comes the empty line"
print $0
}
-----------------------
file displaying without its empty lines
awk '{
if (NF != 0)
{
# print "Here comes the empty line"
print $0
}
}' a.sh
}' a.sh | wc -l
HERE
NF=number of fields in the current line
$0=current line
No comments:
Post a Comment