I am trying to write line which increases variable count to number of words in file:
count=$(($count + $(wc -w $file)))
But i get this error:
0 + 55 <filename>: syntax error in expression (error token is "<filename>")
How can i fix it?
When you give filename arguments to
wc, each line of output contains the requested counts followed by the filename, so you'll know which file each count applies to.
If you don't want the filename included in the output, use input redirection instead of filename arguments.
count=$(($count + $(wc -w < "$file")))