DEV Community

Amanda Igwe
Amanda Igwe

Posted on

2 1 1 2

Day 15/ 30 Days of Linux Mastery: Understanding the 'wc' Command

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

w1 description

  • Check the number of lines in this file
wc -l wcdemo.txt      # This counts the lines in the file
Enter fullscreen mode Exit fullscreen mode

w5 description

  • Count the number of words
bash
wc -w wcdemo.txt 

Enter fullscreen mode Exit fullscreen mode

w3 description

  • Count the number of characters
bash
wc -m wcdemo.txt 

Enter fullscreen mode Exit fullscreen mode

w4 description

  • Count the longest line of the file
bash
wc -L wcdemo.txt 

Enter fullscreen mode Exit fullscreen mode

Image description


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

DevCycle image

Ship Faster, Stay Flexible.

DevCycle is the first feature flag platform with OpenFeature built-in to every open source SDK, designed to help developers ship faster while avoiding vendor-lock in.

Start shipping

Top comments (0)

ACI image

ACI.dev: Fully Open-source AI Agent Tool-Use Infra (Composio Alternative)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Check out our GitHub!