AtSim1 AtSim1 - 1 month ago 4x
Bash Question

Printing line from file in bash script

I have a .txt file which contains text.

Line 1
Line 2
Line 3
End of file aka last line

How can I get print lines from the file and print them to the terminal using a bash script?

Is it possible to use a while loop to get line by line from the txt file and print them out ?


To read a file, line by line, you can use this:

while read line; do
    echo $line
done < file