LinuxQuestions.org
Register a domain and help support LQ
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-15-2012, 09:40 PM   #1
calicowboy54
LQ Newbie
 
Registered: Jan 2012
Location: Huntington beach CA
Distribution: RH, CentOS
Posts: 6

Rep: Reputation: Disabled
Need to move folders older than 5 days to a bad up directory


I need to move folders that are 5 days old from Directory A and all there contents to Directory B

Can anyone help with that


folders are named

20111228
20111229
20111230
20111231
20120101

and need to be moved to


/opt/nas_share_link/archives
 
Old 01-15-2012, 09:45 PM   #2
wagscat123
Member
 
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 13.2, 42.1, and 42.2, OS X 10.10, Ubuntu 16.04, and Linux Mint 17.3
Posts: 545
Blog Entries: 9

Rep: Reputation: 58
Here's how you can do it from a terminal. Go to in a terminal to the folder where the files are. Then type:
[CODE]
$ cp -R 20111228 /usr/nas_share_link/archives
[CODE]
Substitute in the new folder name as you copy a the other folders.
 
Old 01-15-2012, 09:49 PM   #3
calicowboy54
LQ Newbie
 
Registered: Jan 2012
Location: Huntington beach CA
Distribution: RH, CentOS
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wagscat123 View Post
Here's how you can do it from a terminal. Go to in a terminal to the folder where the files are. Then type:
[CODE]
$ cp -R 20111228 /usr/nas_share_link/archives
[CODE]
Substitute in the new folder name as you copy a the other folders.
Sorry i need to be more specific...

i need to Script this out where there are about 50files in Directory /var/logfiles/

they are stored in directories named like this

20111228

I need to move all the folders in that directory that are older than 5 days to another directory called /usr/nas_share_link/archvies

this is due to limited space on the /var/ directory so i need to move stuff off as new folders are being created with data inside them......

thanks
 
Old 01-15-2012, 10:27 PM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,542
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Moderator response

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place.
Duplicate thread http://www.linuxquestions.org/questi...0/#post4575479 has been closed.

Please read the LQ Rules.
 
Old 01-15-2012, 10:27 PM   #5
djlewis78
LQ Newbie
 
Registered: Mar 2008
Location: Aucklnad
Distribution: Debian
Posts: 3

Rep: Reputation: 0
can you not just use

find /var/logfiles/ -type d -ctime +5 -exec mv '{}' /usr/nas_share_link/archvies \;

havent tested it but is should be close to working.
 
  


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
need command to move folders older than 4 days to a bad up directory calicowboy54 Linux - General 4 01-15-2012 10:24 PM
Move Folders Older than X, excluding one folder firegs Linux - General 4 06-02-2011 03:47 PM
Shell script to copy all folders older than 7 days from Linux to Windows by samba blackthu80 Linux - General 4 03-17-2011 01:29 AM
removing directory having file older than 4 days irfanb146 Linux - Newbie 4 05-08-2008 12:05 PM
How to move files older than 30 days gfem AIX 8 11-08-2006 05:58 AM


All times are GMT -5. The time now is 10:31 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