13. A file foo contains a list of filenames. Devise a single statement, with suitable explanation, that stores in a variable namedcount the total character count of the contents of these files. (HINT: Both command substitution and cat have to be used twice). 15 Points
I'm not asking to do my homework for me, just to help me. I know what my problem is. I just cannot figure out how to take the cat'd output from foo, and perform a word count ON the filenames listed in the file.
count=$(cat foo ) | wc -m) ; echo $count
Since foo contains
foo2
foo3
it's outputting correctly 10.
However, foo2 and foo3 contain a total of 9 characters. I've been beating my head against a wall now trying to figure out how to hand the content of "foo" as arguments for wc. If anyone can throw some advice my way, I'd really appreciate it.
Thanks TW.
I'm not asking to do my homework for me, just to help me. I know what my problem is. I just cannot figure out how to take the cat'd output from foo, and perform a word count ON the filenames listed in the file.
count=$(cat foo ) | wc -m) ; echo $count
Since foo contains
foo2
foo3
it's outputting correctly 10.
However, foo2 and foo3 contain a total of 9 characters. I've been beating my head against a wall now trying to figure out how to hand the content of "foo" as arguments for wc. If anyone can throw some advice my way, I'd really appreciate it.
Thanks TW.