[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Maybe offtopic: Dealing with filenames with blanks in a script



> Once you've properly globbed, always surround variable expansion with
> double quotes:
>   for i in * ; do cat "$1" ; done
> 
> This will keep the filename together when passed on the command line to
> another command (cat in this case). cat will not see the filename as two
> (or more) filenames.
> 
> In any script you write, if a variable holds a filename it is always a
> good idea to enclose the expansion in double quotes.
> 
> Sometimes you want to operate recursively on a set of files, where the
> directories or filename will have spaces in them. In that case, using
> the -print0 command to find(1) and the -0 option to xargs(1) gets around
> the problems. eg:
> 
>   find . -print0 | xargs -0 cat
> 
> The -print0 and -0 command line options tell find and xargs to use
> null-terminated strings, not space terminated words.
> 


These both works!! Now I'll mess a little more with the real script...

Thankyou very much.



Reply to: