[Ilugc] cp command with retaining permission

  • From: suresh1876@xxxxxxxxx (Suresh Kumar)
  • Date: Fri Nov 12 17:56:15 2010

On Fri, Nov 12, 2010 at 5:25 PM, steve <steve@xxxxxxxxxxxx> wrote:

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 "!"

 okay thanks steve., will check with it.



cheers,
- steve


Other related posts: