Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a shell script that counts a number of unique word
contained in the file and print them in alphabetical order
line by line?

Answer Posted / arup

#!/bin/csh
# Here tr -s ' ' replaces all multiple ' ' with single ' '
# next pipe the above stream to replace each ' ' with '\n'
# next pipe the above stream to get a sorted list of words
# then pipe the unique words to outfile
tr -s ' ' < $1 | tr ' ' '\n' | sort | uniq > $1.out

Is This Answer Correct ?    20 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I run a powershell script?

1144


what is info area how many types?

2770


Why is a script important?

1075


Explain how you Automate your application using Shell scripting.

2322


What is the use of echo in shell script?

1012


What does $$ mean in shell script?

1061


Which is better perl or shell scripting?

997


What is shell and terminal?

1008


What is @echo off?

1024


What is the difference between bash and shell?

1128


What does $0 mean in shell script?

1012


What's the difference between scripting and coding?

1189


What are the 3 standard streams in linux?

1142


Explain about gui scripting?

1099


Calculate a real number calculation directly from the terminal and not any shell script.

1226