GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
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.
This is a very simple problem. but i was not able to find solution.
Lets say a folder has 5 Files. In this 2 files were created 3 days and other files are older than 5 days.
How do we find, using linux shell script the name of files which have been created in the past 3 days (with respect to the current date).
For example, in the above example, if I excute the shell script today, 2 files names should be displayed.
If I execute the same shell script after 10 days, none of the files names should be displayed.
The mtime option sorts by the last time a file was modified. Assuming the files are created and then left alone, it would work in this case. If the files are being edited after creation, we're up a creek without a paddle. There is no standard way to store creation date for a file. If it's absolutely important that you know the date (albeit not the time) a file was created, you may want to run a script from cron, on a daily basis, to manually discover new files and record their appearance. It still won't be perfect because a file could be removed and later replaced by one with the same name and it would appear older than it actually was by that method.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.