Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I suggest you to use a date format that do not have slashes in it, because it could make the handle of file a bit more difficult, since its get confused with the path specification: for instance, in the hypothetical file /dir/dir2/01/17/06-01/23/06, "01/17/06" is part of path or part of filename ?
So, I suggest you to use a military format like 20060117-20060123. A good side effect is those files are sorted in a chronological way, rather than a numeric way.
To get a date formated in such way, use the formating capabilities of date.
$ date +%Y%m%d
20060124
When you create the Sunday file, create it with this timestamp in the name so you will be able to extract it later to create the composite version 20060117-20060123 you wanted.
I am not sure I understand "be able to post dates into the concatenated file", but "date +%Y%m%d > catted" will create an empty file with the string "20060124" in the first line.
I understand how to insert dates into the file now. Do you know of any logic to work with dates in the past? I need to be able to assign a date to each day of the week. I need to be able to do Sunday, [last Sunday's date] for each day of the week.
This script will run at about midnight Sunday morning every week, so the script needs to be able to automatically calculate the dates for the past week, accounting for months and years. Is there some script code somewhere that already does this?
Uhmmm.... Let say you already have the dates you want. Lets say today is Sunday Jan 29. What if you already have a file named lastSunday with the string 20060122 on it (and a lastMonday, etc) ? So you can use its contents to your purposes, right ?
My idea is to have two set of scripts. The one you are writing to deal with the files. The another one, runs everyday and just create the files lastMonday, lastTuesday, etc with the strings on it. When Sunday comes in, you already have all files with the strings on it. It's helps ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.