Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


The "wc" Utility

July 19, 1998

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]

The "spell" Utility
Introduction to UNIX for Web Developers | Table of Contents
The "cut" Utility


Up to => Home / Internet / UNIX / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers