count lines wihtout comments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aparajita
    New Member
    • Mar 2008
    • 8

    count lines wihtout comments

    How can i copunt no of lines in a ksh script without counting the commented lines..
    is there any single line command
  • micmast
    New Member
    • Mar 2008
    • 144

    #2
    reverse a grep then count

    grep -v \# | wc -l

    Comment

    • aparajita
      New Member
      • Mar 2008
      • 8

      #3
      Originally posted by micmast
      reverse a grep then count

      grep -v \# | wc -l

      Thanks a lot.
      Really

      Comment

      • radoulov
        New Member
        • Jun 2007
        • 34

        #4
        Or:

        Code:
        grep -c '^[^#]' file

        Comment

        • aparajita
          New Member
          • Mar 2008
          • 8

          #5
          Thanks a Lot for the alternative solutio

          Comment

          • ghostdog74
            Recognized Expert Contributor
            • Apr 2006
            • 511

            #6
            Originally posted by micmast
            reverse a grep then count

            grep -v \# | wc -l
            it really depends on where "#" is.

            Comment

            Working...