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 to rename all the files in a folder having specific extension? Example: I have some files with extension (.txt) in a folder name 'Test'. I have to rename all the .txt files in a test and its subdirectories to .my extension.

15 Answers   Interra IT,


What is shell geeksforgeeks?

0 Answers  


If one dont know how to create a script then how he/she can use the QTP?

1 Answers  


A file has multiple records each having three 30-bit long fields(field1,field2,field3).There is also a lookup file,LOOK_UP.dat.Now, we need to consider only the last ten digits of field1 and lookup the file LOOK_UP.dat. If there a match then field2 and field3 should replaced with corresponding data from the lookup file. otherwise that particular record,for which there is no match, should be stored in a seperate file.

2 Answers   Wipro,


When should shell programming/scripting not be used?

0 Answers  






What does the sh command do?

0 Answers  


write a shell script to identify the given string is palindrome or not?

17 Answers   CTS, HP, IBM, InfoEst, Wipro,


What is computer cli?

0 Answers  


What does echo mean in scripting?

0 Answers  


how to read systems current date and time

4 Answers  


is this growing field and what is average package in this?

0 Answers  


How will you print the login names of all users on a system?

0 Answers  


Categories