How to read a file line by line in bash scripting?
This script reads demonstrate how to read a file line by line.
#!/bin/bash
FILE=$1
# Redirect the contents of the file to stdin. This line can be removed if the lines will be piped to this script.
exec<$FILE
read line
while [[ "$line" != "" ]]
do
# Process the line here
#
done
#!/bin/bash
FILE=$1
# Redirect the contents of the file to stdin. This line can be removed if the lines will be piped to this script.
exec<$FILE
read line
while [[ "$line" != "" ]]
do
# Process the line here
#
done
0 Comments:
Post a Comment
<< Home