Sponsored Content
Full Discussion: Date Comparision in the File
Top Forums Shell Programming and Scripting Date Comparision in the File Post 302337174 by edidataguy on Thursday 23rd of July 2009 02:06:54 PM
Old 07-23-2009
Try this:
Code:
ls -1 inbox/sat/ras.sat.trn.* > files.txt

Code:
todate=$(date -d "100 day ago" +%Y%m%d)
while read str ; do
filedate=$(echo $str | cut -d. -f4)
if [[ $filedate < $todate ]] ; then
 echo "Dont move"  # for testing only
else
 echo "Move it"    # mv $str newdir
fi
done < files.txt        # inbox/sat/files.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

date comparision

Hello, I am trying to compare two dates which are in variables and i am not getting the correct result as expected. $first_date = '07/19/2007' $second_date='07/20/2007' Can you please suggest how to i check whether they are equal or not. if ($first_date -eq $second_date) condition is not... (3 Replies)
Discussion started by: kotasateesh
3 Replies

2. Solaris

date comparision

I am wriitng a shell script to compare a date in `date +%Y%m%d%H%M` to the output of `cat /var/adm/messages.0 | grep Temp |grep "CPU Fans" | cut -f1-4,19 -d' '` which looks like Dec 2 11:30:57 79 Dec 2 11:37:58 79 Dec 2 11:44:58 79 Dec 2 11:50:59 79 Dec 2 11:58:00 79 Dec 2... (1 Reply)
Discussion started by: Hitesh Shah
1 Replies

3. Shell Programming and Scripting

Problem with Date Comparision

Hi, I have a file which has the date in the last line in the example pasted along with the rates of the countries. -- I want to compare the date in the last line of the file mentioned in the example below with the system date from Monday to Friday. -- If system date is equal to the date... (2 Replies)
Discussion started by: Raji_gadam
2 Replies

4. Shell Programming and Scripting

problem in date comparision

#!/bin/ksh var="2009-08-31 12:39:05 UTC" ddate=`echo $var|cut -d' ' -f1` y1=`echo $ddate|cut -d'-' -f1` m1=`echo $ddate|cut -d'-' -f2` d1=`echo $ddate|cut -d'-' -f3` filedate=$y1$m1$d1 currdate="20070814" if ]; then echo "$LINE -> $filedate LOWER THAN $currdate" ... (0 Replies)
Discussion started by: HemaV
0 Replies

5. Programming

Problem with date comparision in Pro*C

Hi, I have written the following Pro*C program to get the difference between 2 dates.But when I am printing the value of the date difference,it is always showing 0. #include<stdio.h> #include<sqlca.h> #include<oraca.h> void main() { EXEC SQL BEGIN DECLARE SECTION; int diff; ... (4 Replies)
Discussion started by: sureshbabuc
4 Replies

6. Shell Programming and Scripting

Date - String comparision

Hi, I am having difficulty to compare a string in a file against a date from a a table and print the latest date. Below are the values. String in File : 2009-12-02 00:37:51 Value Table : 2010-01-10-02.00.49.294758 I have to compare both the values ( Ignore the Microsecond in the table... (5 Replies)
Discussion started by: sam_78_nyc
5 Replies

7. Shell Programming and Scripting

Date Manipulation and Comparision

Hi All, I want to generate quarter dates using awk or anything, by giving a dates as input for example : start_date=2010-01-01 end_date=2010-05-31 output should be: start_date end_date qtr 2010-01-01 2010-03-31 1 2010-04-01 2010-05-31 2 Example 2:... (1 Reply)
Discussion started by: sol_nov
1 Replies

8. Shell Programming and Scripting

File Comparision

Hi All, I want to write a script which will compare two files and tell me if the files are different. Actually my files will be same but order of lines will be different,so diff is not working. I have written a script to do this:- while read line; do cnt=`grep -i $line... (6 Replies)
Discussion started by: prasson_ibm
6 Replies

9. Shell Programming and Scripting

Date comparision in Unix

Hi All, I would need your help to compare dates in my script. Say if I have the dates in a file I need to comapre these dates with yesterday's date and the dates which are older than yesterday needs to be displayed. Example: 03/22/2012 03/24/2012 03/20/2012 03/21/2012 03/12/2012... (1 Reply)
Discussion started by: pdreddy34
1 Replies

10. Shell Programming and Scripting

Date command comparision with a different format

I have a script called " passwd_status " which gives the passwd-s status of my servers. the script output is like below password status for A: abc ks 10/05/115 1 30 ps password status for B: abc ks 09/25/115 1 30 ps password status for C: abc ks 10/10/115 1 30 ps Now , i want to... (1 Reply)
Discussion started by: charanarjun
1 Replies
CALENDAR_CONF(5)					   Sun Grid Engine File Formats 					  CALENDAR_CONF(5)

NAME
calendar_conf - Sun Grid Engine calendar configuration file format DESCRIPTION
calendar_conf reflects the format of the Sun Grid Engine calendar configuration. The definition of calendars is used to specify "on duty" and "off duty" time periods for Sun Grid Engine queues on a time of day, day of week or day of year basis. Various calendars can be imple- mented and the appropriate calendar definition for a certain class of jobs can be attached to a queue. calendar_conf entries can be added, modified and displayed with the -Acal, -acal, -Mcal, -mcal, -scal and -scall options to qconf(1) or with the calendar configuration dialog of the graphical user interface qmon(1). Note, Sun Grid Engine allows backslashes () be used to escape newline ( ewline) characters. The backslash and the newline are replaced with a space (" ") character before any interpretation. FORMAT
calendar_name The name of the calendar to be used when attaching it to queues or when administering the calendar definition. See calendar_name in sge_types(1) for a precise definition of valid calendar names. year The queue status definition on a day of the year basis. This field generally will specify on which days of a year (and optionally at which times on those days) a queue, to which the calendar is attached, will change to a certain state. The syntax of the year field is defined as follows: year:= { NONE | year_day_range_list=daytime_range_list[=state] | year_day_range_list=[daytime_range_list=]state | state} Where o NONE means, no definition is made on the year basis o if a definition is made on the year basis, at least one of year_day_range_list, daytime_range_list and state always have to be present, o all day long is assumed if daytime_range_list is omitted, o switching the queue to "off" (i.e. disabling it) is assumed if state is omitted, o the queue is assumed to be enabled for days neither referenced implicitly (by omitting the year_day_range_list) nor explicitly and the syntactical components are defined as follows: year_day_range_list := {yearday-yearday|yearday},... daytime_range_list := hour[:minute][:second]- hour[:minute][:second],... state := {on|off|suspended} year_day := month_day.month.year month_day := {1|2|...|31} month := {jan|feb|...|dec|1|2|...|12} year := {1970|1971|...|2037} week The queue status definition on a day of the week basis. This field generally will specify on which days of a week (and optionally at which times on those days) a queue, to which the calendar is attached, will change to a certain state. The syntax of the week field is defined as follows: week:= { NONE | week_day_range_list[=daytime_range_list][=state] | [week_day_range_list=]daytime_range_list[=state] | [week_day_range_list=][daytime_range_list=]state} ... Where o NONE means, no definition is made on the week basis o if a definition is made on the week basis, at least one of week_day_range_list, daytime_range_list and state always have to be present, o every day in the week is assumed if week_day_range_list is omitted, o syntax and semantics of daytime_range_list and state are identical to the definition given for the year field above, o the queue is assumed to be enabled for days neither referenced implicitly (by omitting the week_day_range_list) nor explicitly and where week_day_range_list is defined as week_day_range_list := {weekday-weekday|weekday},... week_day := {mon|tue|wed|thu|fri|sat|sun} with week_day ranges the week_day identifiers must be different. SEMANTICS
Successive entries to the year and week fields (separated by blanks) are combined in compliance with the following rule: o "off"-areas are overridden by overlapping "on"- and "suspended"-areas and "suspended"-areas are overridden by "on"-areas. Hence an entry of the form week 12-18 tue=13-17=on means that queues referencing the corresponding calendar are disabled the entire week from 12.00-18.00 with the exception of Tuesday between 13.00-17.00 where the queues are available. o Area overriding occurs only within a year/week basis. If a year entry exists for a day then only the year calendar is taken into account and no area overriding is done with a possibly conflicting week area. o the second time specification in a daytime_range_list may be before the first one and treated as expected. Thus an entry of the form year 12.03.2004=12-11=off causes the queue(s) be disabled 12.03.2004 from 00:00:00 - 10:59:59 and 12:00:00 - 23:59:59. EXAMPLES
(The following examples are contained in the directory $SGE_ROOT/util/resources/calendars). o Night, weekend and public holiday calendar: On public holidays "night" queues are explicitly enabled. On working days queues are disabled between 6.00 and 20.00. Saturday and Sun- day are implicitly handled as enabled times: calendar_name night year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=on week mon-fri=6-20 o Day calendar: On public holidays "day"-queues are disabled. On working days such queues are closed during the night between 20.00 and 6.00, i.e. the queues are also closed on Monday from 0.00 to 6.00 and on Friday from 20.00 to 24.00. On Saturday and Sunday the queues are disabled. calendar_name day year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999 week mon-fri=20-6 sat-sun o Night, weekend and public holiday calendar with suspension: Essentially the same scenario as the first example but queues are suspended instead of switching them "off". calendar_name night_s year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=on week mon-fri=6-20=suspended o Day calendar with suspension: Essentially the same scenario as the second example but queues are suspended instead of switching them "off". calendar_name day_s year 1.1.1999,6.1.1999,28.3.1999,30.3.1999- 31.3.1999,18.5.1999-19.5.1999,3.10.1999,25.12.1999,26 .12.1999=suspended week mon-fri=20-6=suspended sat-sun=suspended o Weekend calendar with suspension, ignoring public holidays: Settings are only done on the week basis, no settings on the year basis (keyword "NONE"). calendar_name weekend_s year NONE week sat-sun=suspended SEE ALSO
sge_intro(1), sge__types(1), qconf(1), queue_conf(5). COPYRIGHT
See sge_intro(1) for a full statement of rights and permissions. SGE 6.2u5 $Date$ CALENDAR_CONF(5)
All times are GMT -4. The time now is 04:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy