Table of Contents
Introduction
Welcome back to Day 15 of this practical Linux challenge! Today, we are diving into one of the most useful Linux commands: wc
.
What is wc
?
wc
stands for word count. It is a simple but powerful tool used to count:
- Lines
- Words
- Characters
- Bytes
- Longest line length
It is often used when inspecting files or piping output from other commands.
Core wc
Commands
More commonly used wc
commands are listed in the table below.
Option | Description |
---|---|
-l |
Count lines |
-w |
Count words |
-c |
Count bytes |
-m |
Count characters |
-L |
Print length of longest line |
Real-World Scenario: wc
Command
Let's create a file and fill it with random words, then perform some wc
commands.
- Create a file called wcdemo.txt
- Check the number of lines in this file
wc -l wcdemo.txt # This counts the lines in the file
- Count the number of words
bash
wc -w wcdemo.txt
- Count the number of characters
bash
wc -m wcdemo.txt
- Count the longest line of the file
bash
wc -L wcdemo.txt
Conclusion
The wc
command is one of those small but mighty tools that makes daily Linux life easier. Whether you are scripting, auditing, or just curious about your system, wc
gives you quick stats that help drive smarter decisions.
If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 16!
Let's Connect!
If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.
#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer
Top comments (0)