Re: [PHP] simple command help
Daniel Brown wrote: On Fri, Feb 29, 2008 at 5:22 AM, Shelley [EMAIL PROTECTED] wrote: Hi all, What's the command to use if I want to remove all the directories and files except 'a.gz' under a directory? There isn't a command in PHP to do this. You'd have to write a script to handle that processing. If you're looking for general Unix/Linux commands, you're in the wrong place, but here's one possible way to do it: sudo chattr +i /path/to/a.gz rm -fR /path sudo chattr -i /path/to/a.gz If you have sudo access (or straight root access, in which case you can su - to root and skip the 'sudo' part of the command), that will set the file attribute to immutable, which means no one - including root or the system itself - can modify or delete that file unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and issue the 'chattr -i filename' command. That's what I wanted. Thanks. I have full priviledge of the directory. -- Cheers, Shelley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] simple command help
Hi all, What's the command to use if I want to remove all the directories and files except 'a.gz' under a directory? Thanks in advance. Regards, Shelley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple command help
What's the command to use if I want to remove all the directories and files except 'a.gz' under a directory? There isn't one. If you're using *nix, you could try this: exec('find ! -name a.gz -maxdepth 1 -exec rm -rf {} \;'); Or something like that. If you're on Windows you'll need someone else... :-) -- Richard Heyes Employ me: http://www.phpguru.org/cv -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple command help
On Fri, Feb 29, 2008 at 5:22 AM, Shelley [EMAIL PROTECTED] wrote: Hi all, What's the command to use if I want to remove all the directories and files except 'a.gz' under a directory? There isn't a command in PHP to do this. You'd have to write a script to handle that processing. If you're looking for general Unix/Linux commands, you're in the wrong place, but here's one possible way to do it: sudo chattr +i /path/to/a.gz rm -fR /path sudo chattr -i /path/to/a.gz If you have sudo access (or straight root access, in which case you can su - to root and skip the 'sudo' part of the command), that will set the file attribute to immutable, which means no one - including root or the system itself - can modify or delete that file unless they have the CAP_LINUX_IMMUTABLE capability (such as root) and issue the 'chattr -i filename' command. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php