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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to create a file called ~/dictwords.txt, which contains the number of words found in the file /usr/share/dict/words.

I already created the file then I removed it because I did it wrong I originally did the echo command. Then I tried this command and was so excited because I thought I was correct.

wc -w /usr/share/dict/words > ~/dictwords.txt

It's still wrong, I am supposed to have just the number, without a file name.

share|improve this question
Solution: use wc -w < /usr/share/dict/words > ~/dictwords.txt. Done. – gniourf_gniourf Jun 25 '14 at 18:17
up vote 2 down vote accepted

By default, wc print result along with filenames. If you want only the result, you must make wc read input from stdin:

</usr/share/dict/words wc -w > ~/dicwords.txt

With your current solution, you can use some other tools to get only the result from wc, like cut, awk, grep...

wc -c /usr/share/dict/words | cut -d' ' -f1 > ~/dicwords.txt
share|improve this answer

Your Answer


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.