Here is a sed(1) script file that should solve your problem. The ^I is just the [Tab] key but it's easier to see.
The "^A" is a CTRL-A character NOT a circumflex followed by an uppercase A. It is used instead of, say, a '+' to avoid possible matches in the data. Here is what the script file does:
1 ) Special case where the date string is the first field in the row and is not preceeded by a tab character,
2 ) Special case where the date string is the last field in the row and is not followed by a tab character,
3 ) The general case where you have a tab, date string, and a tab. It is applied to all of the date fields not covered by the two special cases,
4 ) Replace all occurences of ^A0## which would occur if either the day of month or month in year substring was already two digits,
5 ) Get rid of any stray ^A characters left over when the day of month or month in year substring was only one digit
It's confusing but it works. Let me know if you have any questions.
Last edited by hegemaro; 03-02-2007 at 08:17 PM..
Reason: Replace $TAB with ^I or tab. I goofed the order of day and month too.
Problem : we need a command that will give previous day date and previous day should be mon-fri only.
Example :if we are running a command on Monday , it will give Friday ‘s date not Sunday’s .
Few more restrictions :
Command should be working in NM n/w.
Hard coding of date should be avoided.... (11 Replies)
Hi Experts,
I have a date validation script in that i will validate the date for a given format and search in the logs for that date. The script logic is very simple like below.
Validate_Date()
{
is_valid=1
while
do
date_format=$(date "+$1")
echo -e "Please enter the $2 date like... (6 Replies)
Hi,
in my script, i take the last month by
a=$(date --date '1 month ago' +%Y%m)
i expect that it give me in this month "March" as result 201402,
but linux gave me 201403.
IMPe@ABC123:> ~/date --date '1 month ago' +%Y%m
201403
i'm reasonably confused. Any idea?
Thanks in advance,
... (2 Replies)
Good Morning,
I am working on a pyhton script, where it has to fetch a file from our vendor's server over an ftp.
The file is having a date format of "MMDDYYYY" (i have included in my python script), but when the script is executed it is unable to fetch the file.
At the same time, if i... (1 Reply)
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)
Dear all, today I'm scratching my head with a simple (I believe) issue.
Working with date is quite simple, so if I Need to add some seconds to current time, I'll use:
date --date='+30 seconds' +"%Y-%m-%d %H:%M:%S"But, how to pass the value to add from a variable? I tried the following without... (2 Replies)
hi
#!usr/bin/perl -w
local ($date) = `/sbin/date "+%D %X" ` ;
print $date
when i run this in ksh shell it is giving the below error
sh: /sbin/date: not found
but same code is working and displaying date and time in sh shell.
what could be the reason.
pls help (10 Replies)
:(
---------- Post updated at 01:51 AM ---------- Previous update was at 01:50 AM ----------
Not working
---------- Post updated at 02:04 AM ---------- Previous update was at 01:51 AM ----------
cp -p /home/* home/exp/*.`date`
i am using this (4 Replies)
Hello all,
I'm trying to substract 1 minute from the current date and take the hour and minute (for filename purpose).
1) If I want hour an minute from current time I can use:
timetmp=$(date +"%H:%M")
2) To substract 1 minute from current time I can use:
timetmp=$(date --date "$dte -1... (8 Replies)
Hello,
I could not find the exactly same post here.. so I will explain what I did to get the last month using date command.
I used
date +%Y-%m -d "-1 months"
to get the last month. However, the returned value of above command on 2009/10/31 was 2009 10 and not 2009 09.. and the... (9 Replies)