TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Unix Learnings > [SOLVED] Unix - For loop reading full line

Sourav Gulati
Site Owner
Posts: 83

If you want to read whole/full line in for loop , you need to set IFS(Internal Field Separator) to new line which is by default space as  follows:

#!/bin/bash

OIFS=$IFS #Original Internal field separator

# Setting Internal Field Separator to new line

IFS="

"

for line in `cat filename`

do

echo $line

done

           

 



--


January 9, 2013 at 4:21 AM Flag Quote & Reply

You must login to post.