![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search files between a date range | zcanji | Shell Programming and Scripting | 7 | 05-27-2009 12:31 PM |
| How can i copy files by date last modifed range? | geauxsaints | UNIX for Advanced & Expert Users | 4 | 05-25-2008 11: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 11:24 AM |
| Sorting Files by date and moving files in date order | rebel64 | Shell Programming and Scripting | 2 | 03-11-2008 12:45 PM |
| cp only files in certain date range | ee7klt | UNIX for Dummies Questions & Answers | 1 | 06-27-2005 09:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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 ![]() |
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|