LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to move folders older than 5 days to a bad up directory (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-move-folders-older-than-5-days-to-a-bad-up-directory-923951/)

calicowboy54 01-15-2012 08:40 PM

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

wagscat123 01-15-2012 08:45 PM

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.

calicowboy54 01-15-2012 08:49 PM

Quote:

Originally Posted by wagscat123 (Post 4575483)
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

onebuck 01-15-2012 09:27 PM

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.

djlewis78 01-15-2012 09:27 PM

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.


All times are GMT -5. The time now is 03:50 PM.