Find the answer to your Linux question:
Results 1 to 2 of 2
Can you find an alternative for Code: wc -l using grep? Thanks....
  1. #1
    Just Joined!
    Join Date
    Feb 2011
    Posts
    22

    [SOLVED] wc -l and grep

    Can you find an alternative for
    Code:
    wc -l
    using grep?

    Thanks.

  2. #2
    Linux Newbie Nagarjuna's Avatar
    Join Date
    Feb 2011
    Posts
    122
    What exactly is it that your trying to achieve that you can't use wc -l for? Do you lack access to the wc command?

    I don't see how it will be possible to use grep as a complete alternative to wc. You can use the following command to have grep count lines, but it will only be the lines that grep extracted out of the file that match the pattern it was searching for:

    Code:
    grep -c
    This command will suppress grep's normal output and simply prints out the total of lines matching your pattern.

    Unless someone knows better than I, 'grep -c' will be the closest thing to wc that grep can get

    I hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...