Register
It is currently Tue Sep 30, 2014 7:51 am

remove the ".0" of a date


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Sep 03, 2012 9:13 am   

Joined: Mon Sep 03, 2012 9:02 am
Posts: 1
Hi,

I want to transform a txt. I want to remove the ".0" of the dates only (after the time, there is ".0" that I dont need.).

I.e

1480.1 1.0 1.0 2012-07-08 23:38:11.0 2012-07-08 23:40:14.0

I want to transform this line to get this new one...

1480.1 1.0 1.0 2012-07-08 23:38:11 2012-07-08 23:40:14

here's the gawk I am using


gawk -F"." '$1~/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/ { print $1 substr($2,2) } ' MKT_ESTADO_CONSUMIDOR_WEB.TXT

It's ok if I don't have other "." in the line

i.e
from this line...
1479 9 0 2012-07-06 10:58:13.0 null

I get this one

1479 9 0 2012-07-06 10:58:13 null


Top
 Profile  
 PostPosted: Fri Sep 07, 2012 6:29 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Hi!

Code:
awk '/\.0/ { i = NF - 3; while (i++ < NF) sub(/\.0$/, _, $i) } 1' MKT_ESTADO_CONSUMIDOR_WEB.TXT


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP