Share this post with your friends
If you want to know how many words are there in a given file on Linux from the command line, you can use the
The format of
You can use the long option or the short option for counting words using the
wc command for counting words:
Short command format:
wc -w file_path
Long command format:
wc --words file_path
Example - Counting the number of words on the file
Remember that, this file is only available on Ubuntu or debian based operating systems in that location. If you're using other Linux distributions such as CentOS or RedHat, the file should be in
Now let's get back to where we were, Counting the number of words in a apache configuration file.
To count the number of words in apache configuration file, run the following command.
You can see from the output that, the
apache2.conf file on my Ubuntu system contains
1099 words in total.
Tested on: Ubuntu 16.04LTS