Linux bash WC Command

Linux bash WC Command


The wc command counts lines, words, and characters in a file. It can take a -l, -w, or -c option to display only the lines, words, or characters, respectively.

Let's see the few examples with WC command

Without any parameters wc command counts lines, words, and characters in a file.

[root@CentOs ~]# wc /etc/passwd

[root@CentOs ~]# wc /etc/passwd

WC counts only lines with -l option

[root@CentOs ~]# wc -l /etc/passwd

[root@CentOs ~]# wc -l /etc/passwd


WC counts only words with -w option

[root@CentOs ~]# wc -w /etc/passwd

[root@CentOs ~]# wc -w /etc/passwd

WC counts only characters with -c option

[root@CentOs ~]# wc -c /etc/passwd

[root@CentOs ~]# wc -c /etc/passwd

Count two files at once

[root@CentOs ~]# wc /etc/passwd /etc/shadow

[root@CentOs ~]# wc /etc/passwd /etc/shadow


Read wc man page for more..





Tech info

Comments