Search This Blog

Tuesday, February 10, 2009

Counting empty lines in a file

[Count empty lines]
grep '^$' /root/Desktop/chk_services.sh | wc -l

[Count lines which are not empty]
grep -v '^$' /root/Desktop/chk_services.sh | wc -l

[Count lines start with hash #]
grep '^#' /root/Desktop/chk_services.sh | wc -l

[Count lines which dont start with #]
grep -v '^#' /root/Desktop/chk_services.sh | wc -l

No comments:

Post a Comment