Thread: Number of words multiplied by the number of lines in Linux

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    27

    Number of words multiplied by the number of lines in Linux

    You can do that with "wc",

    1. wc - l for the number of lines
    2. wc -w for the number of words

    Hoe should one combine these 2, let's say if I want to multiply the number of words with the number of lines from file a and b respectively?

    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Look into bc and dc.
    My best code is written with the delete key.

  3. #3
    .
    Join Date
    Nov 2003
    Posts
    307
    For a file named e.c:
    Code:
    echo `expr $(cat e.c|wc -l) \* $(cat e.c|wc -c)`

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Number Guessing
    By blacknapalm in forum C Programming
    Replies: 2
    Last Post: 10-01-2008, 01:48 AM
  2. Allocation of major number and minor number linux
    By vinayharitsakp@ in forum Linux Programming
    Replies: 4
    Last Post: 12-08-2007, 02:01 PM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  4. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM