l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2003 Jun 09 11:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Shell Scripting Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Shell Scripting Question



--ZARJHfwaSJQLOEUz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jun 06, 2003 at 11:21:47AM -0700, Ken Herron wrote:
> --On Friday, June 06, 2003 10:34:36 -0700 Henry House=20
> >	find . -path '*/messages/*' -type f -print0 | xargs -0 chmod 777
>=20
> That's fine if the host has gnu find and xargs. If it doesn't,=20

=2E.. you could install them yourself and be done with that minor problem. =
 ;)


  _If_ the system has perl you and for whatever reason installing the
GNU findutils package is not okay, then I recommend you do it in perl and=
=20
not have to worry about weird characters or whitespace in the file names.=
=20

  I imagine a perl script it would also be a few times faster than a pure=
=20
shell script... the following should be functionally equivalent to Henry's
find.

  This script takes a list of directories to look in on the command line,
defaults to '/' if none are given.  Switch the comments on the change_file
function if you want to see what it would do without doing it.

    TTFN,
      Mike Simons

=3D=3D=3D=20
# sub change_file($) { print "chmod 0777, $_[0]\n"; }         # action to t=
ake
sub change_file($) { chmod 0777, $_[0] }                      # action to t=
ake

sub check_dir(@) {
  while ($dir =3D shift @_) {                               # for each dire=
ctory
    $dir .=3D "/" if $dir !~ m#^/$#;         # make sure a '/' is at end of=
 path
    $match =3D $dir =3D~ m#/messages/#;              # regular expression t=
o match

    opendir DIR, "$dir" or next;
    map { lstat "$dir$_";                       # figure out what type of f=
ile
          unshift @_, "$dir$_" if -d _ && $_ ne "." && $_ ne "..";  # add d=
irs
          change_file("$dir$_") if -f _ && $match; # change file if path ma=
tch
        } readdir DIR;
    closedir DIR;
  }
}

check_dir(@ARGV ? @ARGV : "/");               # arguments or '/' if none gi=
ven
=3D=3D=3D=20

--=20
GPG key: http://simons-clan.com/~msimons/gpg/msimons.asc
Fingerprint: 524D A726 77CB 62C9 4D56  8109 E10C 249F B7FA ACBE

--ZARJHfwaSJQLOEUz
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+5MQW4Qwkn7f6rL4RAv++AKCQtgjXsmXgIKI06ZRbrqGoluWv4QCeO3q5
wV6tdRsQECssPkxxg6yWGYk=
=ibgl
-----END PGP SIGNATURE-----

--ZARJHfwaSJQLOEUz--
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech








LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.