Published on April 1, 2017 by ProgrammingKnowledge

How do I read a text file line by line under a Linux or UNIX-like system using BASH shell?
You can use bash loop to read file line by line on a Linux, OSX, or Unix-like system.
There are basically three ways to read file content using bash.
1a: While loop: Single line at a time: Input redirection.
1b: While loop: Single line at a time:
Open the file, read from a file descriptor (in this case file descriptor #4).
2: While loop: Read file into single variable and parse.

My Website –
My Blog –
My Facebook Page –
Google+ –
Twitter –
Pinterest –
Text Case Converter –
Epoch Timestamp Converter –
Decimal – Binary – Hexadecimal Converter –
8-bit Checksum Calculator –

Leave a Reply

1 Comment on "Shell Scripting Tutorial for Beginners 17 – Read a file content in Bash"

Notify of

sansaction l
sansaction l
25 days 4 hours ago

its aprli 1st, i don't trust anything