please look at here to read from a file line by line,So I use the first answer and works:
First answer:
The following (save as rr.sh) reads a file from the command line:
#!/bin/bash
while read line
do
name=$line
echo "Text read from file - $name"
done < $1
Run the script as follows:
chmod +x rr.sh
./rr.sh filename.txt
My question is If I want to read another file line by line , What I should do ? For example this code :
The following (save as rr.sh) reads a file from the command line:
#!/bin/bash
#this read refers to filename.txt
while read line
do
name=$line
echo "Text read from file - $name"
done < $1
.
.
.
#this read refers to file2.txt
while read line
do
name=$line
echo "Text read from file - $name"
done < $1
Run the script as follows:
How I can write this?