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

List:       suse-linux-e
Subject:    [SLE] Brainlocked over recursive script.
From:       Rikard Johnels <rikard.j () rikjoh ! com>
Date:       2006-05-27 10:09:51
Message-ID: 200605271209.59439.rikard.j () rikjoh ! com
[Download RAW message or body]


Hi all!

This is almost embarasing..
I am trying to recursively chmod a series of files.
I tried doing 

  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 " "
(Or get it to understand the complete filename.)
I guess i could (somehow) convert all spaces in both folder and file name to 
underscores, but i dont know how to do that either...

As you probably understood, my scripting knowledge is close to NIL...

Any pointer or hints thankfully received...

-- 
         /Rikard

-----------------------------------------------------------------------------
email   : rikard.j@rikjoh.com
web     : http://www.rikjoh.com
mob:	: +46 (0)763 19 76 25
------------------------ Public PGP fingerprint ----------------------------
< 15 28 DF 78 67 98 B2 16 1F D3 FD C5 59 D4 B6 78  46 1C EE 56 >

[Attachment #3 (application/pgp-signature)]

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

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