Perl how old is a directory




















Can anyone provide an equivalent perl script that deletes all subdirectories and their contents recursively? Sign up to join this community. The best answers are voted up and rise to the top.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Perl script to delete big directory Ask Question.

Asked 6 years, 1 month ago. Active 6 years, 1 month ago. Find centralized, trusted content and collaborate around the technologies you use most.

Connect and share knowledge within a single location that is structured and easy to search. I've used this command to fetch that, but it fails. Because I don't have module installed for File::Find::Rule and it works only for files.

Your code is built in a way that allows it to handle only files older than 90 days, not directories :. Also it is possible to add a mtime rule to the File::Find::Rule search, in order to filter files and dirs by modification date upfront, instead of afterwards in the for loop.

Then it walks the returned paths, and applies the correct deletion method according to the path type file or dir. It also includes a security that prevents the current directory to be deleted, even if it was not modified since 90 days.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. You can use a -d file test operator to check if something is a directory. Here's some of the commonly useful file test operators. Also, try using File::Find which can recurse directories for you.

Here's a sample which looks for directories If not, they deserve everything they get If you want to do it the right way, you can look into File::HomeDir, which is a lot more platform-savvy.

Then all the files in which this string occured should be deleted and only 1 file should remain with the string. I have to write a shell script which can delete all the files and directories recursively inside the specified directory but should not delete the specified directory.

Please some body help me in writing the script. Delete Some Old files from Particular Directory. Hi Team, I am new to scripting. I want to create a script, which needs to keep only 5 days directories and want to remove the old directory from a particular directory.

Can Somebody help me with starting this script. How to delete files within a directory. I'd like to delete ALL files on a daily basis within a directory that are over a day old.

Anyone know how I can automate this through Cron as I have websites to administer. I've tried RedHat Commands. OpenSolaris Commands. Linux Commands. SunOS Commands.



0コメント

  • 1000 / 1000