06-20-2018
Subtract a file's modification date with current date
SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise
Hi,
In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file.
How do I achieve this?
Regards,
Joe
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am a newbie in shell scripting, hope you can advice how can I compare the date/time of file extracted from 'll' and current system date/time.
I have done the following:
ll -rt > $FILE_AGE_LOG
FILE_DATETIME=`more $FILE_AGE_LOG | head -02 | cut -c 45-57`
It returns 'May 4 19:11'.
If I... (4 Replies)
Discussion started by: trexlim
4 Replies
2. Shell Programming and Scripting
I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date.
$file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z
really appreciate any help.
thanks
mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
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
5. UNIX for Dummies Questions & Answers
I'm trying to get the date output to be in the form yyyy-mm-dd (e.g. 2013-01-18)
!/bin/sh
modDate=$(stat -c %y $1)
echo $modDate >> $1
When I run this on another file (by typing ./dateScript theFile.txt), I keep getting this message:
stat: illegal option -- c
What's wrong with my code... (2 Replies)
Discussion started by: Nate18
2 Replies
6. HP-UX
current date command runs well
awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
subtract 30 days fails
awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat
awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
7. Linux
Hi,
My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies
8. UNIX for Beginners Questions & Answers
We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below:
abc.txt
------------------
Code:
line1
line2
line3
$$EDWS_DATE_INSERT=08-27-2019
line4
$$EDWS_PREV_DATE_INSERT=08-26-2019
I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies
9. UNIX for Beginners Questions & Answers
I Have text like
XXX_20190908.csv.gz need to replace Only date in this format with current date every day
Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
DATE(1) General Commands Manual DATE(1)
NAME
date - print or set the date and time
SYNOPSIS
date [-qsu] [[MMDDYY]hhmm[ss]] [+format]
OPTIONS
-q Read the date from stdin
-s Set the time (implicit for -q or a date string)
-u Print the date as GMT
-t Use this number of seconds instead of current time
EXAMPLES
date # Print the date and time
date 0221921610 # Set date to Feb 21, 1992 at 4:10 p.m.
DESCRIPTION
With the -q flag or a numeric argument, date sets the GMT time and date. MMDDYY refers to the month, day, and year; hhmmss refers to the
hour, minute and second. Each of the six fields must be exactly two digits, no more and no less. date always display the date and time,
with the default format for the system. The -u flag request GMT time instead of local time. A format may be specified with a + followed
by a printf-like string with the following options:
%% % character
%A Name of the day
%B Name of the month
%D mm/dd/yy
%H Decimal hour on 2 digits
%I Decimal hour modulo 12 on 2 digits
%M Decimal minute on 2 digits
%S Decimal seconds on 2 digits
%T HH:MM:SS
%U Decimal week number, Sunday being first day of week
%W Decimal week number, Monday being first day of week
%X Same as %T
%Y Decimal year on 4 digits
%Z Time Zone (if any)
%a Abbreviated name of the day
%b Abbreviated name of the month
%c Appropriate date & time (default format)
%d Decimal day of the month on 2 digits
%e Same as %d, but a space replaces leading 0
%h Same as %b
%j Decimal dey of the year on 3 digits
%m Decimal month on 2 digits
%n Newline character
%p AM or PM
%r 12-hour clock time with AM/PM
%s Number of seconds since the epoch
%t Tab character
%w Decimal day of the week (0=Sunday)
%x Same as %D
%y Decimal year on 2 digits
SEE ALSO
time(2), ctime(3), readclock(8).
DATE(1)