Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: To Delete folders older than 14 days.-Want one liner command

by rrrrr (Novice)
on Sep 17, 2012 at 05:37 UTC ( [id://993970]=note: print w/replies, xml ) Need Help??


in reply to Re: To Delete folders older than 14 days.-Want one liner command
in thread To Delete folders older than 14 days.-Want one liner command

Kcott thanks for ur reply. I tried as u suggested but below code showing parameter not correct error. Kindly help me . And I used ls-l its not recognized. Regards rrrrr

#!/usr/bin/perl my $command=`find D/Archieve/Test -type d -mtime +14 -exec rm -rf {} \ +\;`; system $command; print $command;
  • Comment on Re^2: To Delete folders older than 14 days.-Want one liner command
  • Download Code

Replies are listed 'Best First'.
Re^3: To Delete folders older than 14 days.-Want one liner command
by kcott (Archbishop) on Sep 17, 2012 at 07:26 UTC

    ls is one of the very first *nix commands one learns. By writing ls-l, and not seeing why that is wrong, you give the impression that you have virtually no *nix knowledge. I'd seek out a tutorial before proceeding further - perhaps ask your system administrator. You may end up doing irreparable damage using dangerous commands such as rm -rf when you don't really appear to know what you're doing.

    I suggested using system instead of backticks; not in addition to backticks. I took the time to provide you with a link to the system command; perhaps you could take the time to read the documentation it points to.

    You originally showed this path /D/archieve/Test; now you show D/Archieve/Test. (I'm even wondering whether that should be Archive or archive in the middle of the pathname.) Find out what the real pathname is before deleting directories and all their contents recursively and forcefully!

    -- Ken

      Hi Ken, Am working in Java Projects. Previosuly some Locate command was there but not deleting the folders. So I got this task to delete the archieved folder based on modification days.I am just going to implement this one line command in already written prog.So oly in search of one line command.Then I am testing in Development Region only so chnging the path and testing. When I searched I got this Find command. Am trying all ways of find command but either its showing invalid switch or parameter not correct error. Kindly asssit me.

      #!/usr/bin/perl system("find /D/maestro/TestDelete -mtime +4 -exec ls -l {} \\");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://993970]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found