eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to UNIX for Web Developers
The "wc" Utility  
The "wc" utility is used to count the number of words, characters or lines in a file and includes several useful options.

Option Explanation
-c Counts only characters
-l Counts only the number of lines (newline delimited)
-w Counts words only (defined as separated by a tab, space or newline)

Consider these examples of options in use

[wc Example]

Another cool way to use "wc" is to count the number of files in a directory by piping the output of "ls" to "wc" such as:

ls -l | wc -l

Finally, as with other commands, you can use the back tick (`) character to perform command substitution. Thus, the following command will count the number of files in the current directory and the one just above it. (Note you may have to subtract any header lines depending on your version of "ls" as in the version shown below in which we need to extract the lines total 5 and total 8)

expr `ls -l | wc -l` + `ls -l .. | wc -l`

[wc Complex Example]

Previous | Next | Table of Contents