Help with wordcount

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with wordcount
# 1  
Old 09-15-2011
Help with wordcount

Hi, this is my first post so bare with me

I have a file which I want to count the amounts of the same line in the file and display by using a shell script

for example


i would like the output to be
apple 2
apple. 1
bananas 1

however, i need this script to be flexible as it will not always be counting the same things
is this possible?

Thanks for any help you can give

Last edited by radoulov; 09-15-2011 at 12:36 PM.. Reason: Code tags!
# 2  
Old 09-15-2011

sort infile | uniq -c

This User Gave Thanks to radoulov For This Post:
# 3  
Old 09-16-2011
Thanks alot for that it worked a treat Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Math with wordcount output

Hi I know very little about unix. I have a unix code (which I'm running in geektools) which gives me the word count of a pages document. However, the pages document innately contains 522 words of superfluous "Ipsem Lorem..." text which are included in the count. How would I go about... (4 Replies)
Discussion started by: eunoia7
4 Replies

2. Shell Programming and Scripting

test wordcount

Hello I want to run this test: If wordcount of a command is 0 then echo XXXX else echo YYYYY if ; then echo "all devices are created on RAID10"; else echo "Some devices are created on non-RAID10"; fi I receive this message -bash: command substitution: line 1: syntax error near... (3 Replies)
Discussion started by: melanie_pfefer
3 Replies
Login or Register to Ask a Question