[prev in list] [next in list] [prev in thread] [next in thread] 

List:       suse-linux-e
Subject:    Re: [SLE] Brainlocked over recursive script.
From:       Leendert Meyer <leen.meyer () home ! nl>
Date:       2006-05-29 12:56:16
Message-ID: 200605291456.16715.leen.meyer () home ! nl
[Download RAW message or body]

On Saturday 27 May 2006 12:09, Rikard Johnels wrote:
>   ls -R *  | while read f
>    do
>      if [ -f $f ]; then
>        chmod 644 $f
>       fi
>   done
>
> Unfortunately the filenames contain spaces...
> And thus i get all kinds of errors from the chmod stage
>
> 2004 So Called Chaos
> -bash: [: too many arguments
>
> And the stupid part is i cant for my life understand how to get the script
> to enclose the $f with " "

I did not test it, but I would code it as this:

ls -R * |
while read f; do
  if [ -f "$f" ]; then
    chmod 644 "$f"
  fi
done

Cheers,

Leen

-- 
Check the headers for your unsubscription address
For additional commands send e-mail to suse-linux-e-help@suse.com
Also check the archives at http://lists.suse.com
Please read the FAQs: suse-linux-e-faq@suse.com



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic