Files
Lee Hanken 7c8efd2228 Initial commit: HPR Knowledge Base MCP Server
- MCP server with stdio transport for local use
- Search episodes, transcripts, hosts, and series
- 4,511 episodes with metadata and transcripts
- Data loader with in-memory JSON storage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 10:54:13 +00:00

129 lines
7.9 KiB
Plaintext

Episode: 972
Title: HPR0972: LiTS 005: wc
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr0972/hpr0972.mp3
Transcribed: 2025-10-08 05:52:26
---
Welcome to Linux in the Shell episode 5, my name is Dan Washgo, I will be your host today.
We are going to talk about the WC or word count command, but first I want to thank hacker
public radio for their support and remind you that if you have not already read entry
on the website, head over there to Linuxinachel.org and do so to get the full write up of this
audio entry and also to see the video of the examples provided.
So without further ado, let's talk about the word count command or WC.
Ever wanted to know how many lines are in a file?
How many words or how many characters, well you can find that out using the WC command.
Very simple.
WC command itself takes either one or more files as its input or you can use standard
in if you would like to either piping it to WC or if you need to include it along with
other files, you use the dash in conjunction with the other files listed, we'll cover
that in just a minute.
But first, this as an example, if you had a file that was a poem and you would type WC
poem.text, the output of that file would show you very clearly the total number of lines
in the file, the total number of words in the file and the total number of characters
in the file.
So by default, understand that the characters are going to be the total number of single
bike characters, not multi-bike characters.
So chances are you're not going to be using a multi-bike character set, but that'll list
the total number of characters of bytes.
So for instance, if I did WC poem.txt like I had in the right up, it would tell you first
the number of lines, and in this case it's 9, the number of words in there, and in this
case it's 40, and then the total number of characters in there, which is 215, and then
the name of the file was listed.
So it lists those in a columnar format, and the last column is the actual file, and
that's kind of important because if you would pass multiple files in there like WC file
1, file 2, file 3, and so on, it would list those values for each one of those files on
a separate line.
And then what it does with more than one file is it totals the sum of all the lines,
some of all the words, and some of all the characters, and it lists those values as the
last entry under total.
So I had said that you can pass standard in, so the output of a command is standard in
to the WC command, and you can pass that in conjunction with the number of files.
Be aware that when you do that, if you're going to have additional files in there, the
standard in coming in needs to be represented by a dash, so you would do W, like cat, some
file name, pipe, WC file 1, file 2, dash, file 3, file 4, and so on, however you wanted
to do that, then the output of that is going to show you the values for file 1, the values
for file 2, and then it's going to show you for the values for dash, and it's going to
represent the name of that quote file as the dash, and then file 3, file 4 and present
you with the totals.
There are a few options that you can pass to the WC command that limit the exact output.
The first option is dash c, or the dash dash, bytes command, and that prints out the bytes
command.
Now remember, bytes are probably going to be almost exactly the number of characters in
the file if you're using a single byte character set, so you can, you can use that.
There's also dash m, which is character, or dash dash c, h, a, r, s, which is character
counts.
It actually counts the total number of characters, so if you're using a multi-bite character set,
you might get a different representation between bytes and characters, so just keep that in
your mind.
Chances are you'll never encounter a difference between the two.
Dash l, or dash dash lines, is lists out the total number of lines in the file, and that
goes one line is the line of text until the new line character, so it'll just print out
the total number of lines.
And then, of course, there is the dash w, or dash dash words, which will print out the
total number of words in the file.
Now words would include numbers also, so if you had a number in there that would be counted
as a word, be aware of that.
There's a dash capital L, which is dash dash max, dash line, dash length.
Now that will print out the length of the longest line in a file.
It will go through that file, give you the total number of characters, and look at the
total number of characters in a line, then it will print out the length of the longest
line.
It won't actually print out the line, but it'll tell you the longest line in this file
is x number of characters long.
That's pretty much the extent of the wc command.
There is one other option that could possibly be a little confusing in chances are you might
never use it.
But there's an option called dash dash files 0 dash from, and it's got an equals after
that.
Now that reads input from a list of file, or file specified by null terminated names in
a file listed.
This is kind of a complex one little confusing.
The info page shows an example of using this, so if you did info wc at the bottom of the
info page.
Basically, what you need to pass to wc in this case is a list of files, and each list
each file has to be terminated by an asking null character, and then it will be processed
by the wc command.
For instance, their example is using the fine command, so be find dot for current directory
space dash name, and then some naming string like you can have in quotes asteris.txt and
close the quote, and then dash print 0.
So instead of getting the usual output of all the files in the current directory that
are named dot txt on each file with a new line, it prints out an asking null character for
the print 0.
And then pass it to wc and process it with dash dash files, 0 dash from equals, and then
the dash for standard in because you're outputting it.
Now I don't, again, you can do this also, you can create a text file of file names in there.
But instead of putting anything after the file, you'd enter like, let's say you had three
files, it would be file one file, two file, three, and you created a file dot list file.
And then that file, that list, if you wanted to create it in VIM, via improved, you would
put file one and then hit control V and then one zero.
And that will put in the asking null character and then file two control V null zero file
three control V, sorry, one zero, and it puts the null characters in there and you could
use that file then and pass it to wc it will work, but it also tends to throw an error
in the test that I have used.
So it tends to throw an error at the end that says the listings for the files in there
and then at the end, wc, colon, colon, space, no such file or directory.
So somewhere it's still processing a new line character at the end, so just be aware of
it.
I don't know how often you'll be using the dash dash files, dash from option to wc,
but be aware that you have to pass the values with no asking null characters, not new lines
or anything else.
That is pretty much it for the wc command.
I thank you very much.
Head on over to linuxnishell.org for the full write up and the watch the video and we'll
see you later.
Have a great day.
You have been listening to Hacker Public Radio, or Hacker Public Radio, those aren't.
We are a community podcast network that releases shows every weekday Monday through Friday.
Today's show, like all our shows, was contributed by a HBR listener by yourself.
If you ever consider recording a podcast, then visit our website to find out how easy
it really is.
Hacker Public Radio was founded by the digital dog pound and the infonomicum computer
club.
HBR is funded by the binary revolution at binref.com.
All binref projects are crowd-responsive by linear pages.
From shared hosting to custom private clouds, go to lunarpages.com for all your hosting
needs.
Unless otherwise stasis, today's show is released under a creative commons, attribution,
share a line, free those own license.