sh scripting question

John Levine johnl at
Fri Oct 16 17:53:10 UTC 2020

In article <CAHzLAVGS_8kXtWoP3TfpTtz-zP57rpYEKrx3L089=eRRszsY-Q at> you write:
>On Thu, Oct 15, 2020 at 8:40 PM Robert Huff <roberthuff at> wrote:
>>         I have a file ("files.list") with a list of filenames, similar to
>>         /path A/path B/FreeBSD is great.txt
>>         (note the embedded spaces)

This is the sensible answer.  Messing with IFS is very fragile.

>$ while read line; do
>> echo $line
>> done <
>/path A/path B/FreeBSD is great.txt
>/path T/path Q/FreeBSD rocks.txt

The "read" command can set more than one variable so

while read a b c
done < files.list

will set $a to the first word on each line, $b to the second, $c to
the rest of the line, which looks like what you wanted to do here.

More information about the freebsd-questions mailing list