Originally Posted by vinaytp
In the below script, how will the "read line" come to know about the first line of the file entered as argument...
You can rewrite your script like this:
while read line ; do echo $line ; done < $file1
When it is written this way, you can see that everything from "while" to "done" is really one command. This means that "< $file1" is fed into the command.
For more information, run "help while" at a command prompt:
while: while COMMANDS; do COMMANDS; done
Expand and execute COMMANDS as long as the final command in the
`while' COMMANDS has an exit status of zero.