[K12OSN] Script Error with file names that have spaces

David H. Barr david at okgoodwill.org
Wed Sep 1 15:16:34 UTC 2004


>From http://www.faqs.org/docs/bashman/bashref_9.html:

A non-quoted backslash `\' is the Bash escape character. It preserves
the literal value of the next character that follows, with the exception
of newline. If a \newline pair appears, and the backslash itself is not
quoted, the \newline is treated as a line continuation (that is, it is
removed from the input stream and effectively ignored).

So escape your " with a \

-dBarr.

On Wednesday, September 01, 2004 10:12 AM,
Jim Kronebusch wrote:

> A while back I was provided the following script for changing
> permissions on files: #!/bin/bash for file in /home/Drop/* do
> owner=$(ls -ld $file|awk '{print $3}') chown -R $owner $file Done  
> 
> Now I am running into problems with it not knowing how to handle
> files with spaces in them such as "my homework" instead of
> "myhomework".  Now I know that if I run the commands manually at a
> command line I am able to contain the filename in quotes to solve
> this but I don't know how to incorporate that into this script.  Any
> help would be appreciated.     
> 
> Thanks,
> 
> Jim Kronebusch
> Cotter Tech Department
> 507-453-5188
> jim at winonacotter.org
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.744 / Virus Database: 496 - Release Date: 8/24/2004





More information about the K12OSN mailing list