![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | 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 |
| How can i copy files by date last modifed range? | geauxsaints | UNIX for Advanced & Expert Users | 4 | 05-25-2008 08:06 AM |
| How to display files that have been modifed between a given date range | prathima | UNIX for Dummies Questions & Answers | 1 | 04-02-2008 08:24 AM |
| Sorting Files by date and moving files in date order | rebel64 | Shell Programming and Scripting | 2 | 03-11-2008 08:45 AM |
| Search files between a date range | zcanji | Shell Programming and Scripting | 4 | 09-05-2007 12:38 AM |
| cp only files in certain date range | ee7klt | UNIX for Dummies Questions & Answers | 1 | 06-27-2005 06:35 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
Can someone please help me with this. Actually i want to move files from one directory to another directory , But I just want to move files of a specific data range. For ex: This is my directory which contains all fine. /home/Rooh Then there is a long listing of files. suppose this directory contains files from feb 01 , march01, april 01. But I just want to move files of Feb 01 to another Directory for ex: /home/abd/FILESFEB_01 How can I do this. I have tried alot but somehow I am unable to get the output I want. I have also tried with -mtime but doesn't give me the desired output. Your Help will be highly appreciated. Thanks. ROOH |
| Forum Sponsor | ||
|
|
|
|||
|
This will move files by month, and will only work if there is no white-space in the file's name.
ls -go |sed '/^d/ d' |awk '{ if ( $4 == "Feb" ) print $7 } |xargs -i mv {} /home/abd/FILESFEB_01/ Sometimes usernames can bleed over to group IDs in a long listing, which would mess up the awk statement. So use option g and o to remove the owner and group columns. sed is there to remove the directories from the listing. awk statement will check the month column to see if it's equal, in this case, to Feb. If it is, it'll print the file name (again, file names with white-space won't work). Finally pass it to xargs. If you're not familiar with xargs, read up on it... very useful in the right situations.
__________________
Potatoes grow in the ground. |
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|