Quote:
Originally Posted by sharath.bv
Hi,
I want to read lines from a file line-by-line and to display those lines on the terminal.
Can any one please provide a shell script for this.
|
This is obviously just a starting point, so please forgive me for asking.
What are you trying to achieve?
To read each line into a variable you could do:
Code:
#!/bin/bash
cat myfile|while read line
do
##perform some checks
echo $line
done
However, this strips out any leading spaces or tab characters, therefore you may not get what you are after.
To do the same thing in Perl (which doesn't strip out leading spaces or tab characters):
Code:
#!/usr/bin/perl
open(INPUT, "myfile") or die "Could not open input file";
while (<INPUT>) {
##perform some checks
print;
}
close(INPUT);