sh scripting question

Manish Jain bourne.identity at hotmail.com
Fri Oct 16 02:40:18 UTC 2020


Corrections: the backslash on the third line is wrong:

 > oldifs="$IFS"
 > IFS=$’\n’
 > for f in "`cat files.list`" \
 > #stuff
 > done
 > IFS="$oldifs"


So that should be :

oldifs="$IFS"
IFS=$’\n’
for f in "`cat files.list`"
#stuff
done
IFS="$oldifs"


Sorry for the typo,
Manish Jain



On 2020-10-16 08:02, Manish Jain wrote:
> 
> 
> On 2020-10-16 06:30, Robert Huff wrote:
>>
>> Hello:
>>
>>>    Try :
>>>    for FILE in "`cat files.list`"
>>
>>     That's better ... but sets FILE to the entire content of
>> files.list.
>>     I'm trying to pick off one line at a time for further processing.
>>     (I feel like I've done this before - successfully - and for some
>> reason now it's not working.  <Grrrrrr!>)
> 
> Hi Huff,
> 
> 
> You have to set/reset IFS :
> 
> oldifs="$IFS"
> IFS=$’\n’
> for f in "`cat files.list`" \
> #stuff
> done
> IFS="$oldifs"
> 
> Regards,
> Manish Jain


More information about the freebsd-questions mailing list