January 10, 201412 yr 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.
Create an account or sign in to comment