Data/date manipulation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Data/date manipulation
# 1  
Old 01-12-2014
Data/date manipulation

Hallo Team,

I need your help. I would like to change field9 format to yyyy-mm-dd it should be for example 2013-11-16 instead of 20131116

Code:
0780112843,0873599381,E,ISOL,ZAR,0.0035,O,1,20131116,4373200,0.21
0733001720,0873516499,E,ISOL,ZAR,0.0035,O,1,20131116,4331600,0.21
0731069010,0873550144,E,ISOL,ZAR,0.0105,O,3,20131116,4555400,0.21
0839440085,0873540000,E,ISOL,ZAR,0.0805,O,23,20131116,4510200,0.21
0736747788,0873540000,E,ISOL,ZAR,0.0805,O,23,20131116,3351300,0.21
0735600782,0873516481,E,ISOL,ZAR,0.035,O,10,20131116,3305100,0.21
0834538110,0873504345,E,ISOL,ZAR,0.0035,O,1,20131116,3544700,0.21
0836569560,0873537240,E,ISOL,ZAR,0.021,O,6,20131116,2194800,0.21
0832396855,0873540000,E,ISOL,ZAR,0.0805,O,23,20131116,4104000,0.21
0835829767,0873540000,E,ISOL,ZAR,0.0805,O,23,20131116,4041300,0.21
0835829767,0873540000,E,ISOL,ZAR,0.077,O,22,20131116,4044800,0.21
0835829767,0873540000,E,ISOL,ZAR,0.0805,O,23,20131116,4052400,0.21
0738907463,0873539690,E,ISOL,ZAR,0.0035,O,1,20131116,4082800,0.21
0838780516,0873516487,E,ISOL,ZAR,0.035,O,10,20131116,2263000,0.21
0710394006,0873550144,E,ISOL,ZAR,0.1855,O,53,20131116,4215800,0.21
0832924068,0873514889,E,ISOL,ZAR,0.0945,O,27,20131116,4411400,0.21
0787854993,0873504382,E,ISOL,ZAR,0.021,O,6,20131116,4321500,0.21
0733493939,0873550144,E,ISOL,ZAR,0.035,O,10,20131116,4395000,0.21
0781564696,0873504384,E,ISOL,ZAR,0.007,O,2,20131116,3002500,0.21
0732790849,0873540000,E,ISOL,ZAR,0.0525,O,15,20131116,4584500,0.21
0839440085,0873540000,E,ISOL,ZAR,0.07,O,20,20131116,4484000,0.21
0796403431,0312742529,E,ISOL,ZAR,0.021,O,6,20131116,4595300,0.21
0836826338,0114855676,E,ISOL,ZAR,0.056333,O,26,20131116,4424700,0.13
0733871277,0514444643,E,ISOL,ZAR,0.1155,O,33,20131116,2321800,0.21

Regards,

Pax
# 2  
Old 01-12-2014
Try:
Code:
perl -F, -ape '$F[8]=~s/(\d{4})(\d\d)(\d\d)/$1-$2-$3/;$_=join ",", @F' input

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 01-12-2014
Try:
Code:
awk '{sub(/..$/,"-&",$9); sub(/..-/,"-&",$9)}1' FS=, OFS=, file


Last edited by Scrutinizer; 01-12-2014 at 03:57 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 01-12-2014
You gents are the best. Thank you very much.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data manipulation, Please help..

Hello, I have a huge set of data that needs to be reformatted. Here is a simple example to explain the process. I have number n=5 and a input with many numbers separated with comma: ... (11 Replies)
Discussion started by: liuzhencc
11 Replies

2. Shell Programming and Scripting

Date-Manipulation-1

Hallo Team I can perform the task manually but i would like to automate this process. ok here goes. I have a perl script which runs every Wednesday every week and the name of the script is check_19.pl This is how the script looks like : #!/usr/bin/perl -w #use strict; use DBI; #... (1 Reply)
Discussion started by: kekanap
1 Replies

3. UNIX for Dummies Questions & Answers

Data manipulation

Hallo Team, I need to manipulate existing data file. Have a look at current data and expected data: Current Data: 27873517141 27873540000 27873515109 27873517140 27873540001 27873540000 27873501343 27873540000 27873517140 27873511292 27873645989 27873540000 27873540000... (7 Replies)
Discussion started by: kekanap
7 Replies

4. Shell Programming and Scripting

Date manipulation

In my shell script I take date as a input parameter from command line in the format "21 Oct 2011" which would be date +'%d %b %Y' Now i need to do two things here. 1) Validate the date entered by user 2) Calculate yesterday's date from the input. So in this case it should be: "20 Oct 2011"... (9 Replies)
Discussion started by: davidtd
9 Replies

5. Shell Programming and Scripting

Date Manipulation

I have a file with a field containing the following: "7/3/2009 7:07:12 PM","xxxx" I need to be able to split this field up into two into a different format with the time being converted into 24 hour: so that i can get the following: "20090307","19:07:12","xxxx" (8 Replies)
Discussion started by: Pablo_beezo
8 Replies

6. Shell Programming and Scripting

Date manipulation

How can i print a future time, so i get current time by date "+%H:M" but how can i say add 20 minutes to the current time and display as I have just done for current time. (1 Reply)
Discussion started by: kelseyh
1 Replies

7. Shell Programming and Scripting

Date manipulation

Hi Gurus, How to minus 15 minuets from current system time. For example if current time is " Wed Oct 14 12:12:38 BST 2009", i need "Wed Oct 14 11:57:38 BST 2009" Thanks (2 Replies)
Discussion started by: kumarmani
2 Replies

8. Shell Programming and Scripting

date manipulation

HI, I'm comparing my file date with the system date and if both the dates are equal I'm doing some operation. I use two variables for these two dates. I use the following command in my query. if .... But here the current date $cd shows 01 and filedate $fdate shows 1. The file is created on 1 of ... (6 Replies)
Discussion started by: pstanand
6 Replies

9. Shell Programming and Scripting

Date Manipulation

I need to achieve the following.....I seached the forum but could not find it... This is I have in a file... "CH","TIA","10/27/2006",000590 I need the date in the third field to be attached to fileas 20061027_test.txt How do I do it. (6 Replies)
Discussion started by: mgirinath
6 Replies

10. Shell Programming and Scripting

date manipulation

I'm writing a ksh script in which I want to present the user with a choice of choosing any of the last 15 days. i.e., a list like the following: 20040510 (today) 20040509 (yesterday) 20040508 . . . 20040426 Is there an easy way to produce the date from x number of days ago other than... (3 Replies)
Discussion started by: jalburger
3 Replies
Login or Register to Ask a Question