write a shell script that counts a number of unique word
contained in the file and print them in alphabetical order
line by line?

Answers were Sorted based on User's Feedback



write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / 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

write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / phani

cat filename | uniq -u | sort -n

Is This Answer Correct ?    2 Yes 0 No

write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / neennii

sort -u wordtestfile.txt | tee outuniquefile.txt | echo "total unique words are" `wc -w` ; cat outuniquefile.txt

Is This Answer Correct ?    2 Yes 1 No

write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / sathish kumar p

cat << file name >> | uniq | sort -n

Is This Answer Correct ?    0 Yes 0 No

write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / 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

write a shell script that counts a number of unique word contained in the file and print them in a..

Answer / manuswami

$ rm -f res res1 ; while read line ; do cat uniqtest | grep
-wc $line >>res1 ; echo "$line :-> Count=" >>res ;done <uni
qtest ; paste res res1 >final_temp ; cat final_temp|sort -u
>final ; rm -f res res1 final_temp1

Is This Answer Correct ?    1 Yes 8 No

Post New Answer

More Shell Script Interview Questions

How many fields are present in a crontab file and what does each field specify?

0 Answers  


How do I edit a .sh file?

0 Answers  


what is info area how many types?

0 Answers  


How to group the commands in shell scripting?

2 Answers   Polaris,


What is the difference between grep and egrep?

0 Answers  






Why should we use shell scripts?

0 Answers  


What is eval in shell script?

0 Answers  


How will you emulate wc –l using awk?

0 Answers  


What is the difference between a variable and value?

7 Answers   Sun Microsystems,


What is the basic difference you find between a shell script and perl?

3 Answers   Yahoo,


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

0 Answers  


What is the command for " how many shell is running in your system or how many shell supported by your system " ?.

3 Answers  


Categories