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
What is $1 in shell scripting?
What are the default permissions of a file when it is created?
What is difference between shell and bash scripting?
How to redirect both standard output and standard error to the same location?
What does sh mean?
What does $1 mean in bash?
What are the different types of commonly used shells on a typical linux system?
What is awk script?
How do you know which shell I am using?
Where are cowrie shells found?
How would you compare the strings in a shell script?
Write the syntax for "if" conditionals in linux?
What is echo $shell?
What is a scripting language simple definition?
Which scripting language is best for automation?