Skip site navigation (1)Skip section navigation (2)
Date:      16 Oct 2020 13:53:02 -0400
From:      "John Levine" <johnl@iecc.com>
To:        freebsd-questions@freebsd.org
Cc:        vrwmiller@gmail.com
Subject:   Re: sh scripting question
Message-ID:  <20201016175302.CFDB2238515F@ary.qy>
In-Reply-To: <CAHzLAVGS_8kXtWoP3TfpTtz-zP57rpYEKrx3L089=eRRszsY-Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <CAHzLAVGS_8kXtWoP3TfpTtz-zP57rpYEKrx3L089=eRRszsY-Q@mail.gmail.com> you write:
>On Thu, Oct 15, 2020 at 8:40 PM Robert Huff <roberthuff@rcn.com> 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 < f.in
>/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
do
 ...
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.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201016175302.CFDB2238515F>