![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Purge files based on timestamp avl in file name | sureshg_sampat | Shell Programming and Scripting | 3 | 02-29-2008 07:28 AM |
| Using find command for timestamp based search | sunny_03 | UNIX for Dummies Questions & Answers | 1 | 02-12-2008 01:38 AM |
| how to move files into different folders based on filename | italia5 | UNIX for Dummies Questions & Answers | 7 | 08-23-2006 07:04 AM |
| Move client files using UNIX command. | pputh | UNIX for Advanced & Expert Users | 2 | 12-19-2003 01:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
UNIX command: mv - Objective: move files based on timestamp
I was wondering if there was a command to move files from one directory to another subdirectory based on the timestamp, i.e. moving from directory A files that have a timestamp of before the year 2005 into directory B. Directory B is a subdirectory located in directory A. I was advised to concatenate commands mv and find ... printed out the "man find" manual but it didn't make much sense. I also tried googling around but was not able to come upon any sites that talked about either moving files based on the timestamp, or concatenating the mv and find commands.
Please help! Thanks. |
| Forum Sponsor | ||
|
|
|
|||
|
I came across examples of using the find command in the thread ls Help. It looks like probably some variation of a find / -mtime -63 will be included in the command. But how do I concatenate the mv command with the find? I tried searching for "concatenate commands" and "combine commands" in the forum but didn't come up with something that will assist me in this regard. Is there some sort of syntax that's to be followed when telling UNIX to move files that are older than x days old, in the above-example, 63 days old?
--- Edit --- I tried executing mv * /DestinationDirectory/ | find / -mtime -63 but it started to go through the entire mount or something. I saw directories UNIX was checking that I didn't even want it to go through. I was in the directory that I wanted to move the files for that were older than sixty days when I typed pwd to make sure I was in the right location. Last edited by HLee1981; 03-09-2005 at 07:30 PM. |
|
|||
|
You can confine your search to one year by using find with the "-newer" and "! -newer" against files you create with a specific date using "touch".
See this thread but consider setting the "-newer" file to the last minute of the previous year and the "! -newer" to the first minute of the following year. files between any two given dates With a bit of cleverness the year can be a parameter. |
|||
| Google The UNIX and Linux Forums |