sh scripting question

Garance A Drosehn drosih at rpi.edu
Mon Oct 26 01:57:00 UTC 2020


On 15 Oct 2020, at 20:40, Robert Huff 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)
> 	If I use
>
> 	for FILE in `cat files.list`
>
> 	FILE will be set to "/path".
> 	How do I get it to read the entire string?

You will (perhaps) be surprised at how much you can get done with a simple
bourne or bash shell script, if you have something which can look at your
code and give helpful hints.

One way to get those hints would be to use 'shellcheck'.  There is a port
for shellcheck, and you can also try it out at https://www.shellcheck.net
without needing to install anything on your own machines.  Take the code
you wrote, paste it into the shellcheck window, and it'll find whatever
risky things are in that code.  And it will suggest alternatives.  You
can also put comments in your code which will tell shellcheck "Yes, I
really did mean to do this risky thing, so do not warn me about it".

I think it's very useful.

-- 
Garance Alistair Drosehn                =     drosih at rpi.edu
Lead Developer @rpi                   and    gad at FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA


More information about the freebsd-questions mailing list