Jump to content

wc (word count)


Recommended Posts

You can use the command wc to count how many words or lines are in a file and here are some examples:


To count words using wc:

wc -w filename

At the shell prompt, type wc -w (for words) and the name of the file in which you want to count the words.



To count lines with wc:

wc -l filename

Use wc -l followed by the filename to count the lines. This is useful for things like lists.



To count files in a directory

ls | wc -l

Use ls with wc to count the regular files and directories or use ls -A | wc -l to count all files and directories (except for the . and .. directories)



To count bytes of a specific file

wc -c filename

This shows how many bytes a specific file takes up. You could use wc with no flags at all to get the lines, words and bytes of a file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...