Although this is a basic stuff, but still i wonder. Consider these two examples.
Case 1:
[root@dhcppc0 practice]# cat file1 > wc -l
cat: invalid option -- l
Try `cat --help' for more information.
Case 2:
[root@dhcppc0 practice]# cat file1 | wc -l
7
I wonder, why doesn't redirection work in first case? when to use redirect and when to use pipes? I have been Linux for a long time, but still this basic stuff baffles me.
Please help.
cat! (wc -l < file1would have done the same) – slhck♦ Jul 31 '11 at 12:36wc -l file1is even better. – Delan Azabani Jul 31 '11 at 12:48