Peter Newman wrote: > should be in this order (can't chmod before you touch): > 'touch --ref=reffile yourfile && chmod --ref=reffile yourfile'
The order does not matter if the file already exists. But as you saw in my other note I agreed with this order when the file did not previously exist and this creates it. > but what I really want is to have this: > 'touch --ref=reffile yourfile && chmod --ref=reffile yourfile && chown > --ref=reffile yourfile ' Ah... But chown is an entirely different thing and opens up an entirely different box of problems. And it leads me to ask what operating system you are working on? SysV Unix allows non-root users to chown files. BSD Unix and all modern kernels since then only allow the superuser to chown files. > OR as suggested: > 'touch -pr=reffile yourfile' (cause I'm lazy) I am cautious. Is this really something that needs to be done often enough to justify adding the problems of chmod and chown into touch? I think this would be pretty rare and these operations can be done using other commands. > 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 But if the process does not have permission then the proposed enhanced touch won't be able to do this either. > and if you're not then "sudo > file" doesn't work The redirection happens before the sudo. You have to put the redirection into the sudo'd command itself. sudo sh -c '> file' > where "sudo mv log log.old; sudo touch -pr=log.log log" will. Have you looked at using 'savelog' or 'logrotate'? In my opinion this is a task better done by those. Using 'savelog' is a perfect fit here. sudo savelog -p log Do you really want to truncate? Or do you really want to rotate? Those are two different problems. Bob _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
