Shell Script to Display All Words of a File in Ascending Order Last Updated : 19 Jul, 2021 Comments Improve Suggest changes Like Article Like Report Here we will see a shell script that will arrange all the words from a file in ascending order, which comes in handy when we have many words that need to be sorted in ascending order. The script helps to analyze the data easily and represent it in a much more organized manner. Approach: Store the value of the file into a filename variable.Store the words into a TEMP file.Sort the words using the sort command.If TEMP file exists then delete it. Example: There is a File named : words.txt which contain the following word, Input: word.txt. Word.txt contains: creature, assorted, bent. Output: assorted bent creature The Shell Script is given below: # Shell Script to Display All Words of a File in Ascending Order # echo is for printing the message echo -n "Enter name of the file :" # read file name read filename # condition checking if the file exists # if file do not exists the print "file does not exist" if [ ! -f $filename ] then echo "File does not exist" else # in for loop we are comparing the words and storing it in TEMP file for i in $(cat $filename) do echo $i >> "TEMP" done # printing the sorted value in ascending order echo "***SORTED WORDS IN ASCENDING ORDER***" echo "$(sort "TEMP")" fi # condition checking if the TEMP file exists # if the TEMP file already exists then it will delete it if [ -f "TEMP" ] then rm "TEMP" fi Input: words.txt containing 100 words. Output: Comment More infoAdvertise with us Next Article Shell Script to Count Lines and Words in a File M Mandeep_Sheoran Follow Improve Article Tags : Linux-Unix Shell Script Similar Reads Shell Script to Count Lines and Words in a File Linux provides users a great cool feature of the command-line tool along with a graphical user interface where they can perform tasks via ruining command. All of this command returns a status according to their execution. Its execution value can be used for showing errors or take some other action i 6 min read Shell Script to Displays All the Lines Between the Given Line Numbers In this article, We will write a shell script to display all lines between given line numbers to console. We have a file name and start and end line, We have to write a script that will print all the lines from the specified start line to the ending line of the file. Example: File : a.txt Line 1 : H 2 min read Shell Script to Read Data From a File File reading is quite an important task in a Programmer's life as it makes some tasks quite comfortable and automates certain repetitive and time-consuming things. File reading is quite an interesting concept to learn as it gives insight into quite a lot of things that can be done in the Programming 3 min read Shell Script to Perform Operations on a File Most of the time, we use shell scripting to interact with the files. Shell scripting offers some operators as well as some commands to check and perform different properties and functionalities associated with the file. For our convenience, we create a file named 'geeks.txt' and another .sh file (or 5 min read How to set list in descending order in HTML5 ? HTML Lists are used to create informative lists. Any list will have one or more list items. We have three types of lists in HTML. ul: An unordered list is referred to as an ul. Simple bullets would be used to list the items.ol: A number that is arranged in a certain order. This will list the items u 2 min read Write a Bash Script to Print a Particular Line From a File One useful tool for automating operations in Unix-based systems is bash scripting. The need to print a certain line from a file is one such requirement. This post will walk you through writing a basic Bash script that accomplishes that. The fundamentals of utilizing conditional statements, showing t 3 min read Like