top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Reading a file Line by Line in Linux?

+1 vote

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
            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.
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.