wc. The wc command is used to find the number of lines, characters, words, and bytes of a file. To find the number of lines using wc, we add the -l option. This will give us the total number of lines and the name of the file.

How do you count all lines in all files in a directory?

First, the find command fetches all C language files and header files in the src and include directories, respectively. Secondly, all files are passed one by one to wc command via xargs. So the wc command will perform the count of the number of lines for each file.

How do I count the number of lines in multiple files in Linux?

5 Ways to Count the Number of Lines in a File

  1. Count Number Of Lines Using wc Command. …
  2. Count Number Of Lines Using Awk Command. …
  3. Count Number Of Lines Using Sed Command. …
  4. Count Number Of Lines Using Grep Command. …
  5. Count Number Of Lines Using nl and cat Commands.