Read a file line by line
This code demonstrates how to read a file line by line for processing. In this example, we have a simple file
$ cat sample.txt
The code below reads the sample.txt file in the current directory and prints out each individual line.
#!/bin/bash # define input file input="./sample.txt" while IFS= read -r line do # Printing each line echo "$line" done < "$input"