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.
Best Answer
By default,
wc
print result along with filenames. If you want only the result, you must makewc
read input from stdin:With your current solution, you can use some other tools to get only the result from
wc
, likecut
,awk
,grep
...