Login | Sign up

May 24


0

How many lines is this?

Comments (0)

Using the wc command to count lines, words, characters and bytes in files and command output.

If you want to know how many lines a certain command outputs or how many lines are in a file, you can use the wc command to get this information and more.

How many lines in a file

To determine how many lines are in a file:

  1. wc -l <file>

How many lines of output

To check how many lines a certain command is outputting:

  1. <command> | wc -l

Getting other info

You can also retrieve the character count, byte count, and word count by replacing -l with -m, -c, and -w respectively. Examples:

  1. wc -w myreport.txt
  2. echo "How many characters are in this sentence?" | wc -m

The first line will output how many words are in the file myreport.txt and the second line will output the character count that echo will output.


Comments

There are no comments yet.


Post a new comment

Note: Items marked * are required fields

Post a comment

You must login before you can do that.

If you don't have an account, register for free. It's completely private.

Why register

  • rate posts and comments
  • ask questions about posts
  • request new topics/tutorials
  • mark posts as favorites to easily find them again