As an alternative to changing IFS, you can quote or escape the spaces in 
the text file normally and then use eval to run the output through the 
shell parser again before mkdir executes.

dirs.txt:
dir2
dir 3
dir\ 4
dir5
"dir 6 7"

eval mkdir `cat dirs.txt`  # or eval mkdir $(cat dirs.txt), depending on 
your preference for `` or $()

Results in:
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 3/
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 dir/
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 dir 4/
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 dir 6 7/
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 dir2/
drwxr-xr-x  2 cmyers  wheel      68 Jan 23 14:29 dir5/

3 and dir were created since the "dir 3" line didn't have the embedded 
space quoted / escaped, but all of the others were created as expected.

Cheers!

-Chad

On Wednesday, January 16, 2019 at 2:33:22 PM UTC-5, Christopher Stone wrote:
>
> On 01/16/2019, at 08:56, Dave <[email protected] <javascript:>> wrote:
>
> I have a correction to make. I don't think there's actually any way to 
> escape the spaces or quote the folder names in list like this, so if you 
> need to use folder names with spaces (something I avoid, btw) what you need 
> to do is to remove the space charater from the $IFS environment variable, 
> e.g.
>
> ------------------------------
>
> Hey Dave,
>
> Something like this will work:
>
> oldIFS=$IFS; IFS=$'\n'; mkdir `cat ~/Downloads/test.txt`; IFS=$oldIFS
>
> --
> Take Care,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to