Sponsored Content
Full Discussion: Date
Top Forums Shell Programming and Scripting Date Post 302580017 by methyl on Wednesday 7th of December 2011 07:55:22 AM
Old 12-07-2011
Try a cron every Friday at 00:01 to create a file containing the date in the format you want. Then read that file into your script. To set the process in motion create the first file manually.


Btw. felipe.vinturin method will not work on HP-UX because it needs GNU date. It also calculates next Friday, not most recent Friday.
This User Gave Thanks to methyl For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies

2. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

3. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

4. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

5. Shell Programming and Scripting

Check if a date field has date or timestamp or date&timestamp

Hi, In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date&timestamp. I have to figure out the the data is a date or time stamp or date&timestamp. If it is date then append "<space>00:00:00"... (1 Reply)
Discussion started by: machomaddy
1 Replies

6. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

7. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

8. Shell Programming and Scripting

Date: invalid date trying to set Linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" keep giving me this error : date: invalid date ‘19-01-2017 00:05:01' Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies

9. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

10. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies
ctime(3C)																 ctime(3C)

NAME
ctime(), ctime_r(), asctime(), asctime_r(), daylight(), difftime(), gmtime(), gmtime_r(), localtime(), localtime_r(), mktime(), timezone(), tzname(), tzset() - convert date and time to string SYNOPSIS
DESCRIPTION
Convert the broken-down time contained in the structure pointed to by timeptr and return a pointer to a 26-character string in the form: All the fields have constant width. returns NULL and sets errno to if tm_year in is less than 0 or is greater than 8099. In both 32-bit and 64-bit HP-UX, the minimum date supported by is January 1 00:00:00 1900 and the maximum date supported by is December 31 23:59:59 9999. is identical to except that it places the result in the user supplied and returns a pointer to upon success. A buffer length of at least 26 is required. Convert the calendar time pointed to by timer, representing the time in seconds since the Epoch, and return a pointer to the local time in the form of a string. Equivalent to: The minimum date supported by in both 32-bit and 64-bit HP-UX is Friday December 13 20:45:52 UTC 1901. The maximum dates supported by are Tuesday January 19 03:14:07 UTC 2038 and Friday December 31 23:59:59 UTC 9999 in 32-bit HP-UX and 64-bit HP-UX, respectively. In 64-bit HP-UX, returns NULL and sets errno to if timer is less than the number of seconds that corresponds to the mini- mum date supported (i.e., as defined in or exceeds the number of seconds that corresponds to the maximum date supported. is identical to except that it places the result in the user supplied and returns a pointer to upon success. A buffer length of at least 26 is required. Return the difference in seconds between two calendar times: time1 - time0. Convert directly to Coordinated Universal Time (UTC), the time standard used by the HP-UX operating system. returns a pointer to the structure described below. The minimum date supported by in both 32-bit and 64-bit HP-UX is Friday December 13 20:45:52 UTC 1901. The maximum dates supported by are Tuesday January 19 03:14:07 UTC 2038 and Friday December 31 23:59:59 UTC 9999 in 32-bit HP-UX and 64-bit HP-UX, respectively. In 64-bit HP-UX, returns NULL and sets errno to if timer is less than the number of seconds that corresponds to the mini- mum date supported (i.e., as defined in or exceeds the number of seconds that corresponds to the maximum date supported. is identical to except that stores the result in the pointed to by and returns upon success. Correct for the time zone and any summer time zone adjustments (such as Daylight Savings Time in the USA), according to the contents of the environment variable (see below). returns a pointer to the structure described below. The minimum date supported by in both 32-bit and 64-bit HP-UX is Friday December 13 20:45:52 UTC 1901. The maximum dates supported by are Tuesday January 19 03:14:07 UTC 2038 and Friday December 31 23:59:59 UTC 9999 in 32-bit HP-UX and 64-bit HP-UX, respectively. In 64-bit HP-UX, returns NULL and sets errno to if timer is less than the number of seconds that corresponds to the mini- mum date supported (i.e., as defined in or exceeds the number of seconds that corresponds to the maximum date supported. is identical to except that stores the result in the pointed to by and returns upon success. Convert the broken-down time (expressed as local time) in the structure pointed to by timeptr into a calendar time value with the same encoding as that of the values returned by The original values of the and components of the structure are ignored, and the original values of the other compo- nents are not restricted to the ranges indicated below. A positive or zero value for causes to initially presume that Daylight Saving Time respectively is or is not in effect for the specified time. A negative value for causes to attempt to determine whether Daylight Saving Time is in effect for the specified time. Upon successful completion, all the components are set to represent the specified calendar time, but with their values forced to the ranges indicated below. The final value of is not set until and are determined. returns the specified calendar time encoded as a value of type The minimum date supported by in both 32-bit and 64-bit HP-UX is Friday December 13 20:45:52 UTC 1901. The maximum dates supported by are Tuesday January 19 03:14:07 UTC 2038 and Friday December 31 23:59:59 UTC 9999 in 32-bit HP-UX and 64-bit HP-UX, respectively. For 32-bit if the calendar time cannot be represented, the function returns the value and sets to Note the value also corresponds to the time 23:59:59 on Dec 31, 1969 (plus or minus time zone and Daylight Saving Time adjustments). Thus it is necessary to check both the return value and to reliably detect an error condition. The behavior of 64-bit beyond the supported ranges is undefined. Sets the values of the external variables timezone, daylight, and tzname according to the contents of the environment variable (independent of any time value). The functions and (see strftime(3C)) call and use the values returned in the external variables described below for their operations. can also be called directly by the user. When the environment variable is not set, checks the default file for the timezone value and sets timezone values based on that. The file contains the timezone value used by when the environment variable is not set. The format for the file is same as format without the prefix Please check environ(5) for format. If the value of the timezone cannot be determined using the environment variable or the file it is set to the default value of EST5EDT. If the timezone is set to the default value of EST5EDT and the timezone adjustment file is not avail- able, the timezone is set to a default value of UTC (Coordinated Universal Time). can be modified for an appropriate default value for timezone. The header file contains declarations of all relevant functions and externals. It also contains the structure, which includes the follow- ing members: int tm_sec; /* seconds after the minute - [0,61] */ int tm_min; /* minutes after the hour - [0,59] */ int tm_hour; /* hours - [0,23] */ int tm_mday; /* day of month - [1,31] */ int tm_mon; /* month of year - [0,11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday - [0,6] */ int tm_yday; /* days since January 1 - [0,365] */ int tm_isdst; /* daylight savings time flag */ The value of is positive if a summer time zone adjustment such as Daylight Savings Time is in effect, zero if not in effect, and negative if the information is not available. The external variable contains the difference, in seconds, between UTC and local standard time (for example, in the U.S. Eastern time zone (EST), is 5*60*60). The external variable is non-zero only if a summer time zone adjustment is specified in the environment variable. The external variable contains the local standard and local summer time zone abbreviations as specified by the environment variable. EXTERNAL INFLUENCES
Locale The category determines the interpretation of the bytes within format as single and/or multi-byte characters. Environment Variables The function uses the contents of to set the values of the external variables and also determines the time zone name substituted for the and directives and the time zone adjustments performed by and Two methods for specifying a time zone within are described in environ(5). International Code Set Support Single and multibyte character code sets are supported. RETURN VALUE
For and if the buffer is of insufficient length, a NULL is returned and errno set to and return a NULL and set errno to if NULL pointers are passed in as arguments. A NULL is returned and errno is set to if the input to the following routines is not within the supported range: APPLICATION USAGE
The return values for and point to static data whose contents is overwritten by each call. WARNINGS
Users of and should also note that these functions now conform to POSIX.1c. The old prototypes of these functions are supported for compat- ibility with existing DCE applications only. The range of extends to 61 to allow for the occasional one or two leap seconds. However, the "seconds since the Epoch" value returned by (see time(2)) and passed as the timer argument does not include accumulated leap seconds. The structure generated by and will never reflect any leap seconds. Upon successful completion, forces the value of the component to the range [0,59]. AUTHOR
was developed by AT&T and HP. SEE ALSO
time(2), getdate(3C), setlocale(3C), strftime(3C), tztab(4), environ(5), lang(5), langinfo(5), thread_safety(5). STANDARDS CONFORMANCE
ctime(3C)
All times are GMT -4. The time now is 01:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy