Learning Ocean Logo Learning-Ocean
  • Our Courses
  • Blogs
  • About Us
  • Subscribe
  • Disclaimer
Shell Scripting
  • Shell Script Tutorial
  • First Shell Script File
  • Shebang
  • Shell Built-in and Commands
  • Print in Different Colors
  • Comments and Escape Sequences
  • User Define Variables
  • System Variable
  • Input
  • Command Line Arguments
  • Assign a Command's Output
  • Read Only Variable
  • Convert a String
  • Substring
  • Set Default Value
  • Arithmetic Operations
  • Functions
  • Parameters to a Function
  • Local Variable
  • Return Status and Test
  • if With Command
  • if With Numbers
  • if With String
  • if With Files
  • Not Operator
  • and Operator
  • or Operator
  • If-Else
  • Elif
  • Case
  • While Loop
  • Read File
  • Until
  • for Loop
  • for Loop
  • Select
  • Continue
  • Break
  • Nested if Else
  • Nested Loop
  • Project Files

Read File in ShellScript

we can read a file with the help of read and while. The return code of read command is zero, unless the end-of-file is encountered.

#!/bin/bash
file_path="/etc/passwd"
while read line
do
    echo "$line"
    sleep 0.20
done < $file_path

Demo Video

Click Here for Demo Video



PreviousNext