bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: touch: enhancement request to preserve file ownership and permission


From: Peter Newman
Subject: RE: touch: enhancement request to preserve file ownership and permissions
Date: Thu, 13 Sep 2007 14:33:19 +0930


should be in this order (can't chmod before you touch):
'touch --ref=reffile yourfile && chmod --ref=reffile yourfile'

but what I really want is to have this:
'touch --ref=reffile yourfile && chmod --ref=reffile yourfile && chown 
--ref=reffile yourfile '

OR as suggested:
'touch -pr=reffile yourfile' (cause I'm lazy)

I could use a function like:
touchp() {
 F1=$1;
 F2=$2;

 touch --ref=$F2 $F1
 chmod --ref=$F2 $F1
 chown --ref=$F2 $F1
}

where "touchp a b" creates a new empty file with exactly the same 
permissions/ownership

The purpose of this is to clear a log file like this: "> file" but you have to 
be a user with permission to do this and if you're not then "sudo > file" 
doesn't work where "sudo mv log log.old; sudo touch -pr=log.log log" will.



-----Original Message-----
From: Eric Blake [mailto:address@hidden
Sent: Thu 9/13/2007 1:50 PM
To: Peter Newman
Cc: address@hidden
Subject: Re: touch: enhancement request to preserve file ownership and  
permissions
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Peter Newman on 9/12/2007 9:18 PM:
> 
> Add option "-p" to be used only in conjunction with "-r" so that the file 
> owner, group and file permissions are "preserved" (copied) from the 
> referenced file as well as the timestamp.

How is this different from the current two-step process
'chmod --ref=reffile yourfile && touch --ref=reffile yourfile'?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG6LqU84KuGfSFAYARAg6gAKCNe5JbAoMOijT0lhgN4vE/O+YAzwCgv3Ul
uGCrhOZCdiS9W0uLonsHtLM=
=qAUv
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]