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 / trenton g. twining

rm /tmp/$$; \
cat <file> \
| awk '{ for(i=1;i<=NF;i++){ printf("%s\n",$i); }; }' \
| sort -du \
| tee /tmp/$$; \
wc -w /tmp/$$ \
| sed -e "s=/tmp/$$=unique words="

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better perl or shell scripting?

941


What lives in a shell?

892


What is the default shell of solaris?

999


What does egrep mean?

913


Can you write a script to portray how set –x works?

950


What is a shell environment?

940


I have 2 files and I want to print the records which are common to both.

1108


How to print all array elements and their respective indexes?

899


How do I run a bin bash script?

970


What is the syntax of "nested if statement" in shell scripting?

1038


How can we find the process name from its process id?

1125


How do I run a script from command prompt?

996


How to check if a directory exists?

1100


determine the output of the following command: echo ${new:-variable}

913


What is bash coding?

866