DEV Community

Eduardo Issao Ito
Eduardo Issao Ito

Posted on • Updated on

 

Bash: reading lines

Reading lines from a $FILE in bash:

while read LINE
do
    echo "$LINE"
done < $FILE

Reading from standard input:

while read LINE
do
    echo "$LINE"
done <&0

Reading lines from a file as a script parameter, and if it's not found, from standard input:

while read LINE
do
    echo "$LINE"
done < "${1:-/dev/stdin}"

Source: http://mywiki.wooledge.org/BashFAQ/024

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git