-3

I am trying to display a number of lines in a file using grep and word count (wc -l) with a pipe.

I tried many different methods but neither of them wordked. The file is in /home/[User]/[Folder]/[File Name.Extension].

Any suggestion is appreciated.

Thanks,

user3444913
  • 7
  • 1
  • 3
  • 8

1 Answers1

12

You don't need grep to count the number of lines, wc is sufficient :

wc -l filename

should work.

grep is useful only if you wan't to filter the file content, say you want to count the number of lines that contain the word life, then :

grep "life" filename | wc -l

will give you the results.

Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69