music |
| | OSdata.com |
wc
summary
This subchapter looks at wc, a UNIX (and Linux) command.
wc
This subchapter looks at wc, a UNIX (and Linux) command.
wc is used to count lines, characters, and words in a file.
word count command
Use the wc command to count the number of words in your file.
$ wc names
6 6 38 names
$
The format is the number of lines (6), followed by the number of words (6), followed by the number of characters (38), followed by the name of the file (names).
multiple files
You can use the wc command with several file names.
$ wc names file01.txt
6 6 38 names
9 29 134 file01.txt
15 35 172 total
$
The output gives the results for each file (in the order they were listed in the command) and a final line with the totals for al of the files combined.
count the number of lines
Use the wc command with the -l option to count the number of lines in your file.
$ wc -l names
6 names
$
The output is the number of lines and the name of the file.
count the number of words
Use the wc command with the -w option to count the number of words in your file.
$ wc -w names
6 names
$
The output is the number of words and the name of the file.
count the number of characters
Use the wc command with the -m or -c option to count the number of characters in your file.
Solaris and HP-UX use -m.
Linux uses -c.
Mac OS X accepts both -m and -c.
$ wc -c names
38 names
$
The output is the number of characters and the name of the file.
multiple options
You can use multiple options in a single command. The order does not matter. For example, all of the following variations will count the number of lines and words:
$ wc -l -w filename
$ wc -w -l filename
$ wc -lw filename
$ wc -wl filename
comments, suggestions, corrections, criticisms
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
Names and logos of various OSs are trademarks of their respective owners.