How to count words,lines,bytes and chars in a file with Linux OS

To count  Word, Line, Byte and char in Linux You can use ‘wc ‘ command.

To count char in a file  named countfile , ypu can use ‘ -m ‘ or  ‘ –chars ‘ option with ‘ wc ‘ command.

[root@localhost ~]# wc -m countfile
1648 countfile
[root@localhost ~]#

To count word in a file  named countfile , ypu can use ‘ -w ‘ or ‘–words ‘  option with ‘ wc ‘ command.

[root@localhost ~]# wc -w countfile
333 countfile
[root@localhost ~]#

To count byte in a file  named countfile , you can use ‘ -c ‘ or  ‘–bytes ‘  option with ‘ wc ‘ command.

 

[root@localhost ~]# wc -c countfile
1648 countfile
[root@localhost ~]#

To count line in a file  named countfile , you can use ‘ -n ‘ or  ‘–lines ‘  option with ‘ wc ‘ command. 

[root@localhost ~]# wc -l countfile
131 countfile
[root@localhost ~]#

To print  the longest line length in the countfile, you can use ‘ -L ‘ or  ‘–max-line-length ‘  option with ‘ wc ‘ command.

[root@localhost ~]# wc -L countfile
58 countfile
[root@localhost ~]#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s