If you want to know how many words are there in a given file on Linux from the command line, you can use the 'wc' command.
The format of wc command for counting words:
You can use the long option or the short option for counting words using the wc command.
Short command format:
wc -w file_pathLong command format:
wc --words file_pathExample - Counting the number of words on the file /etc/apache2/apache2.conf
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 /etc/httpd directory.
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.
/etc/apache2/apache2.conf 1099 /etc/apache2/apache2.confYou can see from the output that, the apache2.conf file on my Ubuntu system contains 1099 words in total.
Tested on: Ubuntu 16.04LTS
No comments:
Post a Comment