Replacing Date in the file with Create date and timestamp
Hello,
I have files that with a naming convention as shown below. Some of the files have dates in the file name and some of them don't have dates in the file name.
So the file naming convention is: imap-clientname-import-YYYYMMDD.txt
All I am trying to do is: to get the ClientName and Date from the file name. If the Filename does not have dates in their file name, then we put file create date and time.
Also, the output need to be written in a output file with pipe delimitation if possible.
So the output I am looking for is pipe delimitation: clientname and date
hp | 20150917
dell-gec | 20150901
cvs | 20150915
gec | "need a create file date here"
home-depot | "need a create file date here"
I tried something below to get the date. I am getting the desired output. But how to replace it with create date for the files that does not have dates in the filename.
Below is the output I am getting from above code:
20150917
20150901
20150915
import
import
Thank you RudiC for the response. I tried the suggested code but getting the error message below. Also, "la" is not a recognizable command hence changed it to "ls -1". I am using Sun Solaris. Sorry for not mentioning it earlier.
Also, the date which I trying to replace is the create date of the file and not the sysdate.
awk: syntax error near line 4
awk: illegal statement near line 4
awk: syntax error near line 8
awk: illegal statement near line 8
Thank you RudiC for the response. I tried the suggested code but getting the error message below. Also, "la" is not a recognizable command hence changed it to "ls -1". I am using Sun Solaris. Sorry for not mentioning it earlier.
Also, the date which I trying to replace is the create date of the file and not the sysdate.
awk: syntax error near line 4
awk: illegal statement near line 4
awk: syntax error near line 8
awk: illegal statement near line 8
Would appreciate any help on this.
Thanks
use nawk on Solaris instead of awk.
Or as an alternative:
Thank you Vgersh99 for the reply.
It is working fine. The only thing I need in this "need a create file date here" to be replaced by that file creation date on unix system in YYYYMMDD format.
Hi,
I have many files in the source directory but I need to process with the latest timestamp file.
I am using linux operating system. i want extract the file created timestamp( Ext_File_create_date=)
With this format YYYYMMDD-
i have searched the relevent command in the unix forms but did... (5 Replies)
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×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
I want to get maximum/minimum date/timestamp from a data file ?
Sample Input File
=============
rec#,order_dt,ext_ts
1,2010-12-01,2010-12-01 17:55:23.222222
2,2011-11-05,2010-12-01 19:55:23.222222
3,2009-10-01,2010-12-01 18:55:23.222222
for above file
Maximum Order_dt = 2011-11-05... (5 Replies)
Hi,
I've a variable for example..
ACTIVATION_DATE=2010-11-11
(the date above is a result of a sql query and not hardcoded)
now there is another file (test_2.parm) where there are many variables predefined..
REG_CODE=111
ACT_DATE=2010-10-10
CAN_DATE=8888-31-12
Now I want to search for... (1 Reply)
I have a text file that i want to search through and pick out any dates that are formatted like MM/DD/YYYY and replace them with a date i want like 10/29/2009. any idea show i would do this?:)
Snapshot of my text file:
test4>s44syd5172>070>528>ENU>nongnuan>wanrawee>sr2330532>... (7 Replies)
I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)
Hi,
This is my script:
#! /usr/bin/ksh
cd /app/chdata/workflow/suppl/esoutput/spd/testing
for file in /app/chdata/workflow/suppl/esoutput/spd/testing
do
sort *.txt | awk '{ file=substr($0,1,2)".txt"; print >> file }' ... (3 Replies)
Could someone tell me how to get the date/time (to the second) a file was last modified? I need to know if a file was modified in the last 30 seconds from the system date. I'm on AIX/unix 4.3 (3 Replies)
I need to create a file through a c-shell script which contains only the date and time that the file was created. Does anyone know a simple way to do this?
Thank you,
Paula (7 Replies)