Im having a problem with a scripts using dates, this is the problem:
I have a folder for each day, like : 20160711 for yesterday, 20160712 for today, and i want to mv to a backup folder the folders who exceed the year of antiquity (365 days from today) and that script execute every day on my server.
Now, i dont know how to compare every folder with the date from 1 year ago
this command give me in STRING the date of 1 year ago from today no ?
How i can compare that with every folder in my principal folder?
Sorry for my english
Cya and thannks for the help.
Piero.
Moderator's Comments:
Please use CODE tags when displaying sample input, sample output, and code segments.
Last edited by Don Cragun; 07-12-2016 at 08:41 PM..
Reason: Add CODE and ICODE tags.
Im having a problem with a scripts using dates, this is the problem:
I have a folder for each day, like : 20160711 for yesterday, 20160712 for today, and i want to mv to a backup folder the folders who exceed the year of antiquity (365 days from today) and that script execute every day on my server.
Now, i dont know how to compare every folder with the date from 1 year ago
this command give me in STRING the date of 1 year ago from today no ?
How i can compare that with every folder in my principal folder?
Sorry for my english
Cya and thannks for the help.
Piero.
Moderator's Comments:
Please use CODE tags when displaying sample input, sample output, and code segments.
The following is untested, but should come close to what you're trying to do:
This code assumes that you're using a shell that uses the syntax specified by the POSIX standards for shell variable assignment and arithmetic expansions (such as [ksh, bash, ash, zsh, etc.; but not a pure Bourne shell and not a derivative of csh). Obviously, you'll have to change the directory names shown in red to be absolute pathnames to your principal directory and your backup directory, respectively.
Note also that as written, this script will stop working in a little over 883 years. And, it assumes that you don't have any directories created before the year 1000.
I am having below script which needs to be executed based on start and end date
#!/bin/bash
array=('2016-09-27' '2016-10-27' '2016-11-27' '2016-12-27' '2017-01-27' '2017-02-27' '2017-03-27' '2017-04-27' '2017-05-27' '2017-06-27' '2017-07-27' '2017-08-27' '2017-09-27' )
for i in "${array}"
do... (9 Replies)
Hi All,
I have a date variable say dt="2014-01-06 07:18:38"
Now i need to use this variable to search a log and get the entries which occured after that time. (1 Reply)
Hi Sir/Madam
I have a file data.txt like below
file_name date_of_creation
x 2/10/2012
y 8/11/2010
z 11/3/2013
a 2/10/2013
b 3/10/2013
c ... (4 Replies)
Hi.,
After retrieving values from DB I have two datestamps in format:
12/01/2010:05:40:00 AM and 12/01/2010:06:00:00 PM.
general time format: MM/DD/YYYY:HH:MM:SS AM or PM
Any quick solution to get the difference of two in the format : 1 day(s) 12:20:00
Thanks., (6 Replies)
I am attempting to write a script where the user enters the month and day (two digit format). I am trying to have script will increase 6 more times (totaling 7). I am having issues with the script increasing by one (its either dropping off the lead zero or not increasing for 08 and 09). While... (8 Replies)
Good morning all!
I am new to programming and trying to learn; please be patient.
I am wanting to write a script that takes the current date and gzip 5 days or older, then remove 10 days or older.
This is the directory I want to work in; this is what it looks like
... (2 Replies)
Hello friends,
I am looking for a script or method that can display all the dates between any 2 given dates.
Input:
Date 1
290109
Date 2
010209
Output:
300109
310109
Please help me. Thanks. :):confused: (2 Replies)
I am working on a bash script to backup selected servers and am trying to come up with a simpler solution to this problem:
Each server to be backed up has a config file that is read by the script, in the config file are the following values:
LEVEL0=12 #this is the day of the month on which... (3 Replies)