Copying files with spaces in them

Aviss,Tyler tjaviss-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed Jan 28 23:51:18 UTC 2009


Wouldn't that still break on the spaces? If you have a file like "main  
data.dat", you will end up with two values of $file being:
main
data.data

While I agree that spaces may not be a good idea in general for many  
cases, how to make allowances for them in shell scripts?


On 28-Jan-09, at 6:04 PM, "Chris F.A. Johnson" <cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org>  
wrote:

> On Wed, 28 Jan 2009, Christopher Browne wrote:
>
>> I've got a Makefile that is trying to copy man pages into place;
>> unfortunately, since they are (somewhat legitimately) created with
>> spaces in them,
>
>   There's NO excuse for that.
>
>> the following breaks:
>>
>>       for file in $(wildcard man1/*) ; do \
>>         $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man1 || exit;\
>>      done
>>      for file in $(wildcard man7/*) ; do \
>>        $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man7 || exit;\
>>      done
>>
>> I'll bet Chris Johnson would have a better idiom he could suggest  
>> offhand ;-).
>
>    A makefile is not a shell script. In a shell script, I would use:
>
> for file in man1/*
> do
>   cp "$file" "$DESTDIR/$mandir"/man1 || exit
> done
>
> -- 
>   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
>   ========= Do not reply to the From: address; use Reply-To: ========
>   Author:
>   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> --
> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list