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

Is bash an operating system?

542


Explain about the slow execution speed of shells?

773


What is the first line in every perl script called?

551


Is shell scripting difficult?

553


Is shell a scripting language?

570






How are shells born?

549


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2170


What is a batch file used for?

558


How would you compare the strings in a shell script?

543


What are the two files of crontab command?

652


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.

795


How to get the last line from a file using just the terminal?

665


What is inside a seashell?

635


How do I run a shell script on a mac?

625


What is a boot block?

581