How to add a datetime stamp at a particular position in a filename?
hi,
i have some files in a directory say
i am storing these file names in a temp file.
i want to add a date time stamp at a particular place in the file names.
it can be
1) before the extension filename_dateTime.extn (abc_datetime.txt)
2) after the extension filename.extn_datetime (abc.txt_datetime)
there is a variable which contains the place where the date time stamp needs to be added.
stamp_pos which can contain two possible values
i want to parse this string "filename_DT.extn" , and depending on the place where the substring "DT" occurs, i need to add the datetime stamp.
initially i thought, i will 1st read each file name from the temp file(containing list of files in the directory) and also parse the variable stamp_pos and accordingly add substring "DT" to the original file names
suppose,
then the DT will be added as
in the next step i thought i will parse the each original file name and replace DT with the date time stamp.
do anyone has an idea how to do this?
Moderator's Comments:
Please use CODE (not ICODE) tags for multi-line code, sample input, and sample output.
Last edited by Don Cragun; 11-16-2013 at 12:50 PM..
Reason: Fix CODE and ICODE tags.
Hi ,
I want to add a new column 'current_time stamp' in my existing csv file with current time stamp for all the records.I tried something this but this is printing 0 with date & time and printed date one line above header.Please help
awk -F "," 'BEGIN{ OFS="," } {$6=system("date... (5 Replies)
Identify the First Column Position in Second Column and add the position value in 3rd column.
Sample data:
a|c
b|d
c|a
d|b
e|e
f|g
g|f
|h
|i
Expected Output:
a|c|1
b|d|2
c|a|3
d|b|4 (6 Replies)
hi,
A file name is in the form inside a variable
FILE_NAME="s1.txt.xls"
i want to append date and time stamp inbetween s1.txt and .xls. so after appending date time stamp the file name would be
MOD_FILE_NAME="s1.txt.201307251422.xls"
currently i am using the below code... (4 Replies)
I have below scenario where i am getting a flat file but with some bad data
incoming data format
id|name|ind|crncy
123|xxx|y|usd
234|yy|n|
456|a|y90.5|vvv|gbp ----bad dataneed to cleanse the bad data above by adding a pipe '|' after 3rd column 'ind' if pipe '|' is not already there
... (1 Reply)
I have file A.txt
A 1023
B 123
C 1223
I want output
Hello_12PM_A 1023
Hello_12PM_B 123
Helll_12PM_C 1223
Add Hello and time stamp in AM and PM. (4 Replies)
We have a file as shown below with Header and details below Header.Here Header indicates date field.
i Want to add date i.e 20100928 as a first position as shown below without header.Please help us using unix script
Source file:
H20100928
D04041201609360677PC790010384I ... (17 Replies)
I have a Unix directory, let's call it /home/id for example purposes. It contains the following files: oldfile.txt.20091101, oldfile.txt.20091102, oldfile.txt.20091103, etc.
I am trying to create a Korn Shell script that will go to /home/id and delete any oldfile.txt that has a datetime stamp... (1 Reply)
Hi,
New to scripting.
I have datetime as a String and I need to add some hours/minutes in to that.
21/10/2009 23:00:00
After adding 180 minutes; it will look like this
22/10/2009 02:00:00
Regards,
Vikas Mahajan (9 Replies)
Problem discription:
I have many files which contain the same lines.
for instance, (15 lines) file1 ..last column add by hand arbitrarily.
1.78116800 0.68396600 0.00061900
0.47641600 -0.49794500 -0.00024000
-1.70662800 0.29577100 0.67863600
-1.70647600 0.29654600 ... (9 Replies)