For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > September 2006 > capturing the time stamp in desired format









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author capturing the time stamp in desired format
pawan_test

2006-09-21, 7:03 pm

Hello All,

I am working on korn shell script.i have 2 questions;

1) I have a file and i am able to capture the arrival time.
the arrival time is capturing as 11:30

ls -ltr aaa.bbb.332121312.*.* | awk -F" " '{print $8}'

11:30

my desired output is 113000
can anyone please suggest me how do i do this.

2) I have another question.
I have a timestamp as 20060921094743
my desired output is 094743
can anyone please suggest me how do I only display the last 6 digits
from the timestamp.

Thanks a bunch
pavi

Barry Margolin

2006-09-22, 7:01 pm

In article <1158881624.265137.220820@k70g2000cwa.googlegroups.com>,
"pawan_test" <sridhara007@gmail.com> wrote:

> Hello All,
>
> I am working on korn shell script.i have 2 questions;
>
> 1) I have a file and i am able to capture the arrival time.
> the arrival time is capturing as 11:30
>
> ls -ltr aaa.bbb.332121312.*.* | awk -F" " '{print $8}'
>
> 11:30
>
> my desired output is 113000
> can anyone please suggest me how do i do this.


ls -l foo | awk '{sub(":", "", $8); printf("%4s00\n", $8)}'

>
> 2) I have another question.
> I have a timestamp as 20060921094743
> my desired output is 094743
> can anyone please suggest me how do I only display the last 6 digits
> from the timestamp.


Assuming it's in the shell variable $timestamp, use ${timestamp:8}

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com