top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Reading a file Line by Line in Linux?

+1 vote
457 views

I want to read a file line by line, what could be the best way to achieve this?

posted Dec 11, 2013 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Try something like this

    while read line
    do
            echo $line 
    done < $file
answer Dec 11, 2013 by Naveena Garg
use -r flag for read which stands for:
   -r     Do not treat a backslash character in any special way. Consider each backslash to be part of the input line.
...