bash read line from file

Sometimes the readline functionality is required and bash could tackle it.
Seems it needs redirect or pipe to provide data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# !/bin/bash

# using pipe
cat txt | \
while read line
do
echo $line
done

# using redirect
while read line
do
echo $line
done < `cat txt`

bash read line from file
https://rug.al/2014/2014-03-13-bash-read-line-from-file/
Author
Rugal Bernstein
Posted on
March 13, 2014
Licensed under