Connecting Tech Pros Worldwide Forums | Help | Site Map

count lines wihtout comments

Newbie
 
Join Date: Mar 2008
Posts: 8
#1: Mar 25 '08
How can i copunt no of lines in a ksh script without counting the commented lines..
is there any single line command

micmast's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Belgium
Posts: 136
#2: Mar 25 '08

re: count lines wihtout comments


reverse a grep then count

grep -v \# | wc -l
Newbie
 
Join Date: Mar 2008
Posts: 8
#3: Mar 26 '08

re: count lines wihtout comments


Quote:

Originally Posted by micmast

reverse a grep then count

grep -v \# | wc -l


Thanks a lot.
Really
radoulov's Avatar
Member
 
Join Date: Jun 2007
Posts: 34
#4: Mar 28 '08

re: count lines wihtout comments


Or:

Expand|Select|Wrap|Line Numbers
  1. grep -c '^[^#]' file
Newbie
 
Join Date: Mar 2008
Posts: 8
#5: Apr 4 '08

re: count lines wihtout comments


Thanks a Lot for the alternative solutio
Expert
 
Join Date: Apr 2006
Posts: 512
#6: Apr 6 '08

re: count lines wihtout comments


Quote:

Originally Posted by micmast

reverse a grep then count

grep -v \# | wc -l

it really depends on where "#" is.
Reply