Published using Google Docs
Transcript: wc command
Updated automatically every 5 minutes

BYU-Idaho Online Learning

Video Transcript

wc command

Paul: Welcome to Linux essentials, covering your first 100 commands and today we'll demonstrate the WC command. I'm Paul and here's the plan. First, the command and why you need it. Second, we'll play around in our terminal window. And third, we'll return for a quick tip and then we're done. Okay, we know Linux is the backbone of the internet and is used by winners and even bigger winners. At Factor Pad, we use Linux for fun stuff like data visualization. So Linux is great, but it requires that you memorize commands, just like words in a language. And our 26th word or command to memorize is WC from our category text.

[Slide switches from the title page to a slide containing information on the wc command. It displays the term definition, commands, options, and arguments.]

WC allows you to count lines, words, and bytes. Recall from the last few videos we spent time on navigation topics. And now we'll shift back to text for a few videos. Before we start, it helps to think about commands as mini programs, and most follow this structure, command, options, and arguments. The WC command has eight options and arguments are the files on which you'd like to perform the count. Like most commands, help is available with double dash. Without options, WC prints all three: lines, then words, then bytes. To report only one count, use dash L for lines, dash W for words, and make note it's dash C and not dash B for bytes. So why is WC an important command? Well, WC is helpful for monitoring changes to files. And now you know how to do that. Oh, a quick word on navigation. This button goes to the playlist, back one video, forward one video, and click here for updates.

[Paul’s cursor shows us the back and forward buttons at the bottom right corner. These buttons are used to get to different videos. He also shows us the house icon which will lead you to the updates.]

Okay, the best way to embed this in your memory is by typing in your own terminal window. Find this on your Mac using a program called Terminal, on Linux use terminal or console. And currently Microsoft is adding this functionality to Windows.

[The slide switches to the terminal slide where you will write code.] 

[Paul begins to code. He types, “$ wc *” on the first line of the terminal box. On the second line he types, “$ wc –help > video26.txt”. He then writes “$ ls” on the line below the last. Once he’s done that, he types “$ wc -l video26.txt”. Below he writes “$ less -N vidoe26.txt]

Here we go, Let's start with the broadest view using the star wildcard, which shows counts for all of our files, lines, words, and bytes. Second, let's create a file to process by grabbing the help file for WC and output it to a text file called Video 26 dot TXT. Now using WC dash L, and count 22 lines. Let's open with less from Video 5, using the dash n option and look the syntax, eight options and 22 lines. Third, hit Q to leave less.

[Paul opens up another terminal to code in. In this terminal, he types “$ wc -w video26.txt”. Below this line, he types “$ wc –by video26.txt”. He finally ends the code with “$ exit”.]

And for words, WC dash W on video 26, 160. And last, to reinforce two things, byte count is dash C, not dash B. Also recall that double dash, as long as Linux identifies what you mean, it'll work. So double dash BY counts. Pretty neat, huh? Very good. And as always, exit closes the terminal window. 

[Paul returns to the slide with information about the wc command.]

Okay, now you know how to use WC and you know the syntax for commands, options, and arguments. One last tip about the WC command. It really comes in handy to count programs or changes to the number of lines in a log file. Okay, thanks for visiting today, I hope this was a helpful introduction to the WC command.

[End of video.]