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

What are types of shells?

1011


How does path variable work?

951


How would you compare the strings in a shell script?

965


What can you do with powershell?

1110


What is the first line of a shell script called?

1063


What is awk in shell script?

1214


I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?

2149


What is a beat in a script?

1050


Write a shell script that adds two numbers if provided as the command line argument and if the two numbers are not entered throws an error message.

1275


What language is bash written in?

981


How to get the 3rd element/column from each line from a file?

1173


What are the advantages of shell scripting?

1024


How to find all the files modified in less than 3 days and save the record in a text file?

1043


What is shell application?

984


Why is it called a shell?

922