Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-05-2012
Registered User
 

Join Date: Feb 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
output of wc

Hi All,

Can any one tell me the reason of following output .

Code:
$ wc -l < file1 file5
3 file5

$ wc -l < file5 file1
8 file1

My intention was to count lines of file1 and file5. But seems wc is counting lines of only one file. How can i count lines of respective files with their file name ?
content of file1 and file5 are

Code:
$ cat file1
emp
employee
empty1
empty2
empty3
empty4
empty5
errorfile

$ cat file5
a is nice.
i live in london.
london is nice city.
$

Thanks in advance...

Last edited by vbe; 02-05-2012 at 03:33 AM..
Sponsored Links
    #2  
Old 02-05-2012
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 8,506
Thanks: 67
Thanked 401 Times in 390 Posts
Don't redirect ( do not use the < symbol)

Code:
wc -l file1 file2

Sponsored Links
    #3  
Old 02-05-2012
Registered User
 

Join Date: Feb 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Jim for your response.
But my intention is to see behavior of < operator.
As for as i know < should provide file1 and file2
as input to wc -l

But in this case
wc -l < file1 file2

only one file file1 is going as input to wc -l
    #4  
Old 02-05-2012
Scrutinizer's Avatar
mother ate her
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 5,371
Thanks: 80
Thanked 1,107 Times in 1,011 Posts
Input redirection works on only one file, see here: Shell Command Language
To use both files as standard input, you would need to concatenate:

Code:
cat file1 file2 | wc -l


Last edited by Scrutinizer; 02-05-2012 at 04:29 AM..
Sponsored Links
    #5  
Old 02-05-2012
Registered User
 

Join Date: Feb 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thanks I got it.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk: round output or delimit output of arithmatic string jelloir Shell Programming and Scripting 1 06-18-2010 03:07 AM
Converting line output to column based output npatwardhan Shell Programming and Scripting 8 03-24-2010 08:40 AM
top output for six processes with the same name, output changed from column to row Bloke Shell Programming and Scripting 5 06-04-2009 06:02 AM
Expect - Interact output hangs when large output natedog Shell Programming and Scripting 0 08-27-2008 11:21 AM
how to make a line BLINKING in output and also how to increase font size in output mail2sant Shell Programming and Scripting 3 04-14-2008 07:30 AM



All times are GMT -4. The time now is 04:29 AM.