You are not logged in or registered. Please login or register to use the full functionality of this Website SybaseTeam.Com...
Hello There, Guest! (LoginRegister) Remember Me? Current time: 04-19-2015, 01:31 AM
   Home  |  About Us  |  Sybase Training  |  Synergy  |  Consulting  |  Job Openings  |  Tech Videos  |  Rules and Disclaimer  |  Search
Post Reply 
Forum Tools
'wc' command
06-17-2010, 03:06 AM
Post: #1
Quote this message in a reply
'wc' command

'wc' command is used to count the lines, words and characters in an inputfile.


wc [-lwcm] input_file


The following options can be given.

-c count bytes

-w count words

-l count no. of lines

-m count characters

-C same as option 'm'

By default wc will display the no.of lines, words and characters in a given input file.

If multiple files are specified then wc will count the no.of lines, words and characters in each file. It will also dispaly the total no.of lines, words and characters from both files.

Ex: consider the sample.txt file with the below contents

hello this is an example
good morning
welcome to the world of unix !!

The wc command when used on sample.txt will output the following.

$wc sample.txt

3 14 70 sample.txt

Ex: consider another file sample.txt with the following contents

welcome to the world of korn shell programming
unix commands are very powerful
unix shell scripts are equivalent to dos batch files

The wc command when used on sample1.txt will output the following.

$wc sample1.txt

3 22 131 sample1.txt

When both sample.txt and sample1.txt are given as input the following is output.

$wc sample.txt sample1.txt
3 14 70 sample.txt
3 22 131 sample1.txt
6 36 201 total

Think Deeply. Code Well.

Saritha R
Synergy Project (SybaseTeam.Com)
Find all posts by this user
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  'which' command srama2 0 2,094 05-27-2010 08:32 AM
Last Post: srama2
  scp command to transfer files srama2 0 3,639 05-17-2010 08:00 AM
Last Post: srama2
  last command srama2 0 2,334 05-07-2010 06:24 AM
Last Post: srama2
  Powerful usage of sort command in Unix - column wise sorting pavan526 0 11,136 04-24-2010 01:08 PM
Last Post: pavan526
  listing files using 'ls' command srama2 0 3,312 04-23-2010 03:13 AM
Last Post: srama2
  'rmdir' command srama2 0 2,357 04-20-2010 03:18 AM
Last Post: srama2
  Processing Shell Script Options Using getopts Command srama2 0 3,226 04-19-2010 03:41 AM
Last Post: srama2
  cal command srama2 0 2,424 04-14-2010 03:34 AM
Last Post: srama2
  'iostat' command srama2 0 4,196 04-12-2010 06:23 AM
Last Post: srama2
  tee command srama2 0 2,875 04-09-2010 02:44 AM
Last Post: srama2

Forum Jump:

Contact Us | SybaseTeam | Disclaimer & Rules | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication