Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a folder with three files:

$ ls
a  b  c

If I pipe the output of ls to wc, I get the right result:

$ ls | wc -l
3

However, when I specify the input to wc as the output of ls, I get extra text:

$ wc -l <(ls)
3 /dev/fd/63

Can anyone explain to me what is happening?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

wc will tell you what file it's working on if it's able. With the first one with the pipe it's reading from stdin, not a file, so does not report a filename. The second one, however, you're using process substitution which presents the output of the command as a file, which wc reports. It reports on the file descriptor it was given from which to read.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.