getting date from timestamp


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers getting date from timestamp
# 1  
Old 09-28-2006
getting date from timestamp

Hi All,

i have a time stamp. from that i am trying to awk to get the year, month and date.

TIME=20060614092446

DESIRED OUTPUT: 20060614

i am doing the following;

TIME=20060614092446
$ TimeStarted=`expr match '$TIME' '.*\(......\)'`
echo $TimeStarted

i am not getting any output. can anyone please suggest me.

thanks
mark
# 2  
Old 09-28-2006
Code:
expr substr 20060614092446 1 8

or

Code:
expr match 20060614092446 '\(........\).*'

# 3  
Old 09-28-2006
Date conversion

thanks anu
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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. imap-hp-import-20150917.txt imap-dell-gec-import-20150901.txt imap-cvs-import-20150915.txt imap-gec-import.txt... (8 Replies)
Discussion started by: Saanvi1
8 Replies

2. Shell Programming and Scripting

File Timestamp and date comparsion

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)
Discussion started by: onesuri
5 Replies

3. Shell Programming and Scripting

Check if a date field has date or timestamp or date&timestamp

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&timestamp. I have to figure out the the data is a date or time stamp or date&timestamp. If it is date then append "<space>00:00:00"... (1 Reply)
Discussion started by: machomaddy
1 Replies

4. Shell Programming and Scripting

How to convert date and timestamp?

Hi, I have a file file1 having data as below 20110501,070742, ,012345678909,09999999999,68.5, 20110501,070236, ,089375855455,09376383333,374.3, 20110501,070525, ,090345895555,08444233444,206.2, 20110501,230051, ,000934744433,07624262223,480.1, First field is date(YYYYMMDD) and second... (5 Replies)
Discussion started by: vsachan
5 Replies

5. UNIX for Dummies Questions & Answers

Unix timestamp to readable date

How would I convert a unix timestamp such as "1232144092" to a readable date such as "1/16/2009 10:14:28 PM" ? I thought I could use date, but I don't think so now.. Any help would be great!! (4 Replies)
Discussion started by: Rhije
4 Replies

6. Shell Programming and Scripting

Timestamp to date conversion in ksh

Hi, I have a file containing timestamp( Example given below). How can i get date(mmd-dd-yyyy) from it? ($> cat file1.txt 2008-11-24 05:17:00.7043) Thanks, Sri (2 Replies)
Discussion started by: srilaxmi
2 Replies

7. Shell Programming and Scripting

Timestamp & date

Hi, I have list of files as below, with prefix named as date & time. Anyone how to transform each file as below to yyyy-mm-dd hh:mm:ss Regards, (8 Replies)
Discussion started by: rauphelhunter
8 Replies

8. Shell Programming and Scripting

File renaming with date timestamp

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)
Discussion started by: Sunitha_edi82
3 Replies

9. UNIX for Dummies Questions & Answers

get a file date/timestamp

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)
Discussion started by: alex31
3 Replies

10. Shell Programming and Scripting

Creating file with date/timestamp in it

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)
Discussion started by: ccpjr29
7 Replies
Login or Register to Ask a Question