To learn more, see our tips on writing great answers. For example: Thereadcommand expects an input stream literal, and the redirection identifier (<<<) inputs the herestring. Looking for job perks? Dana Bash will become the new anchor of CNNs Inside Politics on weekdays, as current anchor John King moves to a reporting project for the 2024 presidential campaign. This will take the first parameter after the script name as the filename to be used in the script. How can I read each line from a file into one variable for the last field, and another variable for the other fields? NASA just found a way to keep it alive for another 3, despite it being 12 billion miles from Earth. How to avoid a useless use of cat when parsing a file? If total energies differ across different software, how do I decide which software to use? }' file Which was the first Sci-Fi story to predict obnoxious "robo calls"? How can I control PNP and NPN transistors together from one pin? There are two conditions that will satisfy the while loop and allow the text to be processed by the body of the loop: These two clauses are separated by the OR logical operator || so that ifeitherclause returns success, the retrieved text is processed by the body of the loop, whether there is a newline character or not. Note that this is not the same $1 that holds the same data file passed to the script. You can simply use bash redirection and command substitution to get the file contents as arguments to your command: This works because not only space is a valid word splitting character, but newline as well you dont need to substitute anything. How about saving the world? Related: Private Japanese moon lander reaches lunar orbit. How can I avoid that? Elizabeth Howell (she/her), Ph.D., is a staff writer in the spaceflight channel since 2022 covering diversity, education and gaming as well. Apart from the implementation differences, ProcessText3 behaves exactly the same as ProcessText1, except that it does not consider the part between the last newline character in the variable and the end of the variable as line if that part is empty. Only three other countries have soft landed on the moon before: The United States, the Soviet Union and China. Dave is a Linux evangelist and open source advocate.