[SOLVED] Move the files between Current day & a previous day
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Move the files between Current day & a previous day
Hi All,
I have a requirement where I need to first capture the current day & move all the files from a particular directory between the current day & a previous day. (BUS_DATE)
Here is what I am trying, but it gives me errors. ( I think those are syntax errors)
(I notice in your examples you use "date --date=123456789" not "date --date=@123456789". If your version of 'date' doesn't need the @, then just remove it from my code)
You're using date again, feeding it the current date in seconds, but subtracting $i*24*60*60 seconds (which should be $i days' worth of seconds) and then outputting the corresponding date.
Reading the dates from a file & moving the files from a directory
Hi All,
I am coding for a requirement where I need to read a file & get the values of SUB_DATE. Once the dates are found, i need to move the files based on these dates from one directory to another.
ie, this is how it will be in the file,
SUB_DATE = 20120608,20120607,20120606,20120606
Now, i need to move the file (with filename like a.20120608,a.20120607 etc) based on the above dates from /path/source to /path/destination.
Can anybody shed some light on how to achieve this in LINUX?
Could you clarify it a bit more? What are the exact contents of the file? Is it just that line, or are there others? Please post a representative example.
And does each date in the SUB_DATE string match an exact filename? Could there be dates without files, or files without dates, and what should happen in such cases? Please post a sample of the directory tree as well.
In any case, this should all be doable with a simple shell script. A while+read loop, some simple string manipulation, and mv are probably all that's required. Here are some links to start you with:
@dsfreddie: moderator note: your new thread has been merged here, since the new question is strictly related to the previous one. Furthermore, keeping discussions in one place avoids confusion and gives your question a better exposure (in respect of members that already stepped in to help).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.