AIX/awk date to unix timestamp


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users AIX/awk date to unix timestamp
# 1  
Old 12-27-2008
AIX/awk date to unix timestamp

Hello,

I am inside a awk script on AIX, I am feeding to awk ls -luNR

i need to convert ls -u time format "month day h:m/yr" to Unix epoch time, POSIX time, or aka unix timestamp

I do not have strftime funk in my awk, and i have to do this fast meaning that I cannot do a system call in the awk, as my ls returns +40 million files and a system call would slow it down too much.

here is a simple test script, what is the date2epoch CODE I need? Any thoughts, there must be a non messy way?


Code:
#!/bin/ksh
#


dir=${1:-`pwd`}

ls -luNR ${dir} | awk  '

NF >= 9  {
m=$6
d=$7
t=$8
epoch="date2epoch CODE?"

print m " " d " " t " = " epoch
}

'


Last edited by nullwhat; 12-27-2008 at 08:55 PM..
# 2  
Old 12-27-2008
take a look at this link (when the system comes back online).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

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)
Discussion started by: kmarcus
20 Replies

2. Shell Programming and Scripting

Convert date in dd mm yyyy format to UNIX timestamp

Hello All, I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following: date -d $mydate +%s where mydate = 23/12/2016 00:00:00 I am getting following error: date: extra operand `+%s' Try `date --help' for more information. ... (1 Reply)
Discussion started by: angshuman
1 Replies

3. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

4. AIX

convert a specific date to a unix timestamp

hello, i have an AIX5.3 machine and i am writing a script to display some processes. inside the script i want to get the time that the process starts and convert it to a unix timestamp. is there a command that i can use to do that? i search the web but all i found is long scripts and it does... (4 Replies)
Discussion started by: omonoiatis9
4 Replies

5. 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

6. AIX

Get Next month in AIX from curent date in unix AIX

How could we derive teh Next month in MON-RR format from current date ie sysdate in UNI AIX sheel script.I coould get a command but i supports only inLinux susse andnotin AIX. I need for Unix AIX.Pls Help. Regards Shiv (2 Replies)
Discussion started by: SHIV75
2 Replies

7. Shell Programming and Scripting

To convert a date(in string format) to unix timestamp

Hi All, I have a string like below. "Mar 31 2009" . I want to convert this to unix time . Also please let me know how to find the unix time for the above string minus one day. For Eg. if i have string "Mar 31 2009" i want to find the unix time stamp of "Mar 30 2009". Thanks in advance,... (11 Replies)
Discussion started by: girish.raos
11 Replies

8. Shell Programming and Scripting

Separate date timestamp use awk or sed command ?

Hi, I have logfile like this : Actually the format is date format : yyyymmddHHMMSS and i want the log become this format yyyy-mm-dd HH:MM:SS for example 2009-07-19 11:46:52 Can somebody help me ? Thanks in advance (3 Replies)
Discussion started by: justbow
3 Replies

9. 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

10. UNIX for Dummies Questions & Answers

override the system date-timestamp on the Unix servers

I am looking for a tool that allows us to override the system date-timestamp on the Unix servers so that we can perform regression tests using the same set of scripts and data. CDS is an example of a system where the logic is very date/time dependent. It would make regression testing much easier... (5 Replies)
Discussion started by: DavidH
5 Replies
Login or Register to Ask a Question