"Andrew Kennard" schreef:
> I need a word counter to count the number of words in a scientific
> paper. I know it wont be 100% accurate due to formulas etc
echo 'I,Item1,Item2,Item3,a' |
sed 's/[^A-Za-z0-9]/ /g' |
wc
If you want to count only strings with a specific minimum length, use
`strings` as well:
echo 'I,Item1,Item2,Item3,a' |
sed 's/[^A-Za-z0-9]/\n/g' |
strings -2 |
wc -l
(for some seds you need to express the \n differently)
Or use perl:
echo 'I,Item1,Item2,Item3,a' |
perl -aF/[^[:alnum:]]+/ -nle'
print 0+grep length >= 2, @F
'
Alternative:
echo 'I,Item1,Item2,Item3,a' |
perl -aF/[\W_]+/ -ple'
$_=grep length>1,@F
'
See also `perldoc -q count`.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>