LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2010, 02:10 AM   #1
ericczed
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
I need a script that will move all 30 days old files in a folder


Hi,

I`m totally new to linux, in fact I`m a windows admin. I would appreciate any help.

scenario:

I need to run a script that will automatically move 30 days old files from particular folder to a particular folder.

Please help...my boss is pressuring me............

regards,

eric

Last edited by ericczed; 01-22-2010 at 02:11 AM.
 
Old 01-22-2010, 02:57 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,254

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
You'll need the find cmd
Code:
find /Dir1 -type f -mtime +30 -exec mv {} Dir2 \;
Note that find re-curses downwards in Dir1 (src dir); if you don't want sub-dirs checked, use -maxdepth 0
eg
Code:
find /Dir1 -type f -maxdepth 0 -mtime +30 -exec mv {} Dir2 \;
See the man page for 'find' : http://linux.die.net/man/1/find

Test first ...
 
Old 01-23-2010, 09:05 AM   #3
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
Quote:
Originally Posted by ericczed View Post
Hi,

I`m totally new to linux, in fact I`m a windows admin. I would appreciate any help.

scenario:

I need to run a script that will automatically move 30 days old files from particular folder to a particular folder.

Please help...my boss is pressuring me............

regards,

eric
Mark the thread as "[SOLVED]".This option is under the "Thread Tools" above.

It's urgent or this is not encouraged in LQ.
Code:
Please help...my boss is pressuring me............
 
Old 01-23-2010, 09:31 AM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,601
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Hi,

Welcome to LQ!

Quote:
Originally Posted by ericczed View Post
Hi,

I`m totally new to linux, in fact I`m a windows admin. I would appreciate any help.

scenario:

I need to run a script that will automatically move 30 days old files from particular folder to a particular folder.

Please help...my boss is pressuring me............

regards,

eric
Since you have been given a solution then mark the thread via the 'Thread Tools'.

Just a few links to aid yourself in the future;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Advanced Bash-Scripting Guide
Linux Home Networking


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash script needed to move files to another folder. No_one_knows_me Linux - General 28 01-07-2010 11:29 PM
Automated script to DELETE files older than 2 days in a Particular folder siddhartha_ece2004 Linux - Newbie 14 07-11-2008 06:46 AM
How to move files older than 30 days gfem AIX 8 11-08-2006 05:58 AM
How to automatically move files from one folder into another folder? xmrkite Linux - Software 6 11-05-2006 11:39 AM
making a script that will move a file or files in a trash folder Paxmaster Programming 5 12-12-2004 07:00 PM


All times are GMT -5. The time now is 01:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration