[Ilugc] cp command with retaining permission
- From: steve@xxxxxxxxxxxx (steve)
- Date: Fri Nov 12 17:26:21 2010
On 11/12/2010 02:37 PM, Roshan George wrote:
On Fri, 2010-11-12 at 14:09 +0530, Suresh Kumar wrote:
(in
other words not to change the owner and group if it was .. apache )
I might be over-complicating, but you can do this like so:
ls -la | grep -v apache | awk '{print $8}' | xargs chown newwonder:psgrp
You can probably change that a bit to get what you want.
or:
find <pathname> -group <old group> -exec chown <newowner>:<newgroup> {} \;
find is a pretty powerful tool, you should learn its option if you want be good
at sysadmin/shell scripting. Some of the most useful search options are:
-name
-iname
-mtime
-type
-size
-perm
-maxdepth/-mindepth
and the action options:
-exec
-delete
-print/-printf
and of course the operators to combine search options "-a", "-o" and "!"
cheers,
- steve
--
random spiel:
http://lonetwin.net/
what i'm stumbling into:
http://lonetwin.stumbleupon.com/
Other related posts: