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 is the use of .sh file?

610


What is difference between shell and bash scripting?

550


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

2978


What are the four fundamental components of every file system on linux?

1168


What does $@ mean in shell?

594






Is shell a scripting language?

576


What are the different types of shell scripting?

538


What is the significance of the shebang line in shell scripting?

533


What is the equivalent of a file shortcut that we have a window on a linux system?

609


Write a command sequence to find the count of each word?

542


What is path in shell script?

641


What is the significance of $#?

593


What is the best shell scripting language?

541


Why is used in shell scripting?

562


what is info area how many types?

2297