By RafaelZin
via code2learn.com
Published: Nov 05 2012 / 07:45
UNIX doesn't have any real command which helps us to get the number of lines which has records or data in it. But what UNIX offers is to get the number of new lines.
Tweet
SaveShareSend
Tags: methodology, unix-linux
Comments
nikolas.lotz replied ago:
#> cat TEXTFILE | grep -v '^[[:blank:]]*$' | wc -l
RafaelZin replied ago:
Hi Nikolas, Your command would escape the empty lines, but it will fail in the below scenario: 1.Make a file with 2 records one on each line Example: name.dat Rafael (press Enter) Zin (dont press Enter) 2. After the data in 2nd line dont press enter. As discussed above. 3. Now run your command you will get wrong output.
nikolas.lotz replied ago:
Nope. After fixing all the typos in your script ('gerp' vs 'grep' and a few missing backticks) it returns the same result.
nikolas.lotz replied ago:
And another typo: "$nl_coun2" vs "$nl_count2"
Voters For This Link (5)
Voters Against This Link (1)