LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 08: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, 08:45 PM   #2
wagscat123
Member
 
Registered: Jan 2009
Location: Maryland-Pennsylvania border, USA
Distribution: openSUSE 15.2/15.3, Tumbleweed, Kubuntu 18.04/21.04, macOS 10.15, antiX 19, and Linux Mint 19.3
Posts: 860
Blog Entries: 45

Rep: Reputation: 120Reputation: 120
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, 08: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, 09:27 PM   #4
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
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, 09: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



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 09:24 PM
Move Folders Older than X, excluding one folder firegs Linux - General 4 06-02-2011 02: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 12:29 AM
removing directory having file older than 4 days irfanb146 Linux - Newbie 4 05-08-2008 11:05 AM
How to move files older than 30 days gfem AIX 8 11-08-2006 04:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:05 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
Open Source Consulting | Domain Registration