Computing.Net > Forums > Unix > conversion of different timestamp t

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

conversion of different timestamp t

Reply to Message Icon

Name: dprakash
Date: April 14, 2009 at 07:46:27 Pacific
OS: unix
CPU/Ram: 2gb
Subcategory: General
Comment:


hi

i need a scrit to convert one date format to another. for example

i have three columns in a file which gets a different format, but lastly i want output
with stadard timestamp as "yyyy-mm-dd hh:mm:ss"

column1 column2 column3
2/28/2009 8:03 PM Mchenry: Shawna 2/28/2009 8:03 2/28/2009
3/28/2009 6:03 PM phanj: ray 3/28/2009 8:03 3/28/2009
4/8/2009 4:03 PM hcary: jun 4/8/2009 8:03 4/8/2009
2/9/2009 08:03 PM ghtar: jan 2/09/2009 8:03 2/09/2009


coloumn 1 contains a PM and name ...output should be as standard timestamp .
coloumn 2 contains only time stamp ...output should be as standard timestamp .
coloumn 3 contains only date ...output should be as standard timestamp .

output file should contain format as below:

column1 column2 column3
2009-02-28 08:03:00 2009-02-28 08:03:00 2009-02-28 00:00:00
2009-03-28 06:03:00 2009-03-28 08:03:00 2009-03-28 00:00:00
2009-04-08 04:03:00 2009-04-08 08:03:00 2009-04-08 00:00:00
2009-02-09 08:03:00 2009-02-09 08:03:00 2009-02-09 00:00:00

thanks

PRakash



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 14, 2009 at 08:41:01 Pacific
Reply:

What shell are you using?


0

Response Number 2
Name: dprakash
Date: April 14, 2009 at 23:12:08 Pacific
Reply:

ksh we are using.........

could u please share me the logic ...for this


0

Response Number 3
Name: nails
Date: April 15, 2009 at 12:47:59 Pacific
Reply:

I will do the first date-time string for you:

#!/bin/ksh

typeset -Z2 MONTH
typeset -Z2 DAY
typeset -Z5 HRMIN

echo "2/28/2009 8:03 PM Mchenry: Shawna 2/28/2009 8:03 2/28/2009"|while read col1 col2 col3 therest
do
   set -- $(IFS="/"; echo $col1)
   MONTH=$1
   DAY=$2
   YEAR=$3
   HRMIN="$col2"
   printf "%s-%s-%s %s:00\n" "$YEAR" "$MONTH" "$DAY" "$HRMIN"
done


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: conversion of different timestamp t

join 2 files of different length www.computing.net/answers/unix/join-2-files-of-different-length/6363.html

list of different lines in files www.computing.net/answers/unix/list-of-different-lines-in-files/5305.html

Get the last few words of a line? www.computing.net/answers/unix/get-the-last-few-words-of-a-line/7459.html