You said it only works with one column with timestamps, but as RudiC said, your code only works if there is only one column with timestamps and that timestamp is at the end of the line. RudiC's code works for one timestamp anywhere on a line except at the end of a line (and won't work if you have tabs as field separators instead of spaces).
As long as you have a version of sed that conforms to the standards, the following should work no matter how many timestamps you have on a line, no matter where they are placed on a line, and no matter what field separators you use:
If file contains:
the output produced is:
Hi,
Is anybody can help me to get the file creation date with seconds?
-rw-r--r-- 1 opsc system 422550845 Aug 22 15:41 StatData.20020821
Thanks in advance
Krishna (7 Replies)
hi all
how do we get the milli seconds in sun unix?
i am using
date +%Y%m%d%H%M%S
to get the unique id and create the file based on this.
but the problem is that if process to load the table takes only less than 1 sec i am getting errror on my table which have the primary key.
how... (2 Replies)
Hi all!
I'm working on a HPUX system, and I was wondering if there is a simple way to convert a date from seconds (since 1970) to a normal date.
Thanks (2 Replies)
Need a little help developing a ksh script. Have read through Perderabo's datecalc routine and it does not seem to fit the function I am looking for. Basically what I am trying to do is find any file (in a specific directory) that was created within the last five minutes. I am not a programming... (3 Replies)
Hello Friends,
I've been struggling with extreme nagios passive service checks. In order to trigger a nagios passive service im going to write an easy shell script like below and will run it in crontab.
As im working on Solaris 10 servers i used "S" instead of lowercase "s" below
#!/bin/sh... (2 Replies)
I am trying to get date to display decimal
Desired output 1350386096256.12
I know this can be done with printf, but are not able to make it work.
I have tested this and many otherprintf "%.2f" $(($(date +%s%N)/1000000)) (8 Replies)
Hi,
i have a flat file namely temp.txt with this data below
ID|name|contact_date
101|Kay|2013-12-26
102|let|2013-12-26
I need to modify the date data in the flat file into MM/DD/YYYY HH24:MI:SS format
let me know the code for this.
Thank you! (5 Replies)
Hi,
Need to subtract 5 seconds after syncing my Linux server from NTP like;
#ntpdate time.myorg.int.
This script will only run once in each morning at 9 AM.
Please help me. (4 Replies)
Discussion started by: refra
4 Replies
LEARN ABOUT REDHAT
ftime
FTIME(3) Linux Programmer's Manual FTIME(3)NAME
ftime - return date and time
SYNOPSIS
#include <sys/timeb.h>
int ftime(struct timeb *tp);
DESCRIPTION
Return current date and time in tp, which is declared as follows:
struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
Here time is the number of seconds since the epoch, millitm is the number of milliseconds since time seconds since the epoch, timezone is
the local time zone measured in minutes of time west of Greenwich, and dstflag is a flag that, if nonzero, indicates that Daylight Saving
time applies locally during the appropriate part of the year.
These days the contents of the timezone and dstflag fields are undefined.
RETURN VALUE
This function always returns 0.
BUGS
This function is obsolete. Don't use it. If the time in seconds suffices, time(2) can be used; gettimeofday(2) gives microseconds;
clock_gettime(3) gives nanoseconds but is not yet widely available.
Under libc4 and libc5 the millitm field is meaningful. But early glibc2 is buggy and returns 0 there; glibc 2.1.1 is correct again.
HISTORY
The ftime() function appeared in 4.2BSD.
CONFORMING TO
BSD 4.2, POSIX 1003.1-2001.
SEE ALSO gettimeofday(2), time(2)Linux 2001-12-14 FTIME(3)