I am using Korn shell script . It would be great if I can get using awk or sed
It's not a text replacement problem. What if yesterday was last month? How many days was last month again? Is it always the same number of days? What date corresponds to what day of the week? Etc, etc, etc. It's not trivial. Just call something that knows what a date is.
It's possible to do this in some versions of awk. Finding out which one you have will be a game of 20 questions since you don't want to tell us what your system is.
It's possible to do this in some versions of ksh. Finding out which one you have will be a game of 20 questions since you don't want to tell us what your system is.
It's possible to do this in some versions of the date utility. Finding out which one you have will be a game of 20 questions since you don't want to tell us what your system is.
It's possible to do this in any standard installation of Perl. I don't need to know what your system is.
I posted perl because it works in more places than everything else. Anything else depends on having the exact right version of the exact right shell, the exact right version of the exact right nawk, or having a new enough version of the GNU date utility.
I can turn the perl into a one-liner you can embed in ksh or whatever...
Quote:
I tried using awk its not working
What did you try? In what way is it "not working"?
Last edited by Corona688; 07-24-2013 at 06:09 PM..
Well, assuming you have tight definitions of the current week, you can determine that by doing integer divide of unix time / ( 86400 * 7 ) give or take a few days, as 01/01/1970 might not be a Sunday (Thursday, actually, so Sunday of week 0 might be - 4 * 86400). Might want to adjust for time zone as UNIX is GMT. Multiply back the UNIX Week and add in the offset for Tuesday. Between $((...)) and gnu date, you should be fine.
Last edited by DGPickett; 07-24-2013 at 06:02 PM..
I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and
I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server
$ cat temp.txt
RTG*888*TD8*20180201~... (1 Reply)
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)
Hi all,
Need an urgent help on the below scenario.
script:
awk -F","
'BEGIN { #some variable assignment}
{ #some calculation and put values in array}
END {
year=#getting it from array and assume this will be 2014
month=#getting it from array and this will be 05
date=#... (7 Replies)
Hi,
i am writing a ksh shell script to check the last month end date whether it is falling in last 10 week day date, I am not sure How to use "Mr. Perderabo's date calculator", Could you Please let me know how to use to get my requirement, I tried my own script but duplicate week day and... (5 Replies)
Hi ,
Please help me out to write a shell script to obtain the date of first tueday of every month. I am new to shell scripting.
Appreciate your help Thanks. (7 Replies)
Hi,
My job will run every friday and it should pick only that week files.
For Ex: this 24th May job will trigger and it should pick 20,21,22,23,24.and 19th sun and 18th sat we dont have files to pick.
currently i am using the below code and it is working fine, but sometimes it is picking... (3 Replies)
Hi
Can we get every tuesday or monday's date for the current week ?
For the current week i need tuesday's date or monday's date in
%m%d%y fromat
Thanks (5 Replies)
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)
Hi,
Anybody knows how to get what date was 28 days ago of the current system date through UNIX script.
Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)