ls | wc VS wc `ls`
2 posters
ls | wc VS wc `ls`
- Code:
[336474@oracleclient ~]$ ls
f7 tester
[336474@oracleclient ~]$ ls | wc
2 2 10
[336474@oracleclient ~]$ wc `ls`
1 1 17 f7
wc: tester: Is a directory
0 0 0 tester
1 1 17 total
[336474@oracleclient ~]$
note here that both ls | wc and wc `ls` does the same job of giving the output of ls command as input to wc command..
but we get two different outputs. can any one suggest the possible reason for this action???
Re: ls | wc VS wc `ls`
"ls | wc" and "wc `ls`" are not equal.
In "ls | wc", wc receives only one argument which is the output of ls command. In the second command each line of ls command will be passed as argument to wc command.
In ur example, "wc `ls`" is similar to "wc f7 tester"
In "ls | wc", wc receives only one argument which is the output of ls command. In the second command each line of ls command will be passed as argument to wc command.
In ur example, "wc `ls`" is similar to "wc f7 tester"
Permissions in this forum:
You cannot reply to topics in this forum
|
|