• Source
    1. #
    2. #Write a script to display all words of a file in ascending order.
    3. #
    4.  
    5. clear
    6.  
    7. echo -n "Enter name of the file :"
    8. read filename
    9.  
    10.  
    11.  
    12. if [ ! -f $filename ]
    13. then
    14. echo "File does not exist"
    15. else
    16. for i in $(cat $filename)
    17. do
    18. echo $i >> "tempfile"
    19. done
    20. echo "===== SORTED WORDS OF FILES ====="
    21. echo "$(sort "tempfile")"
    22. echo "================================="
    23. fi
    24.  
    25. if [ -f "tempfile" ]
    26. then
    27. rm "tempfile"
    28. fi