Sponsored Content
Full Discussion: awk - change date format
Top Forums Shell Programming and Scripting awk - change date format Post 302761013 by Don Cragun on Friday 25th of January 2013 02:21:11 AM
Old 01-25-2013
Quote:
Originally Posted by vegasluxor
Thanks for your reply.... this is working for the data I gave... but in actual file i also have strings with spaces and it could have : / as well.... but file is comma separated.

eg:
Input file:
number, number, date time, number, string, string
123456789,98765432,9/8/2012 3:00,1, ABC ABC, NEW STRING (12/3)

Need output:
date , time , number , number, number, string, string
20130809,030000,123456789,98765432,1, ABC ABC, NEW STRING (1:23)

Please advise. Sorry for not giving complete data before!
So is the transformation of xy/z to x:yz supposed to occur in both string fields or only in the last field? Will that transformation always be for 2 digits followed by a slash followed by a single digit, or is there some more general pattern?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change of date format

I want to chnage the date format from the file format like below to WT;T15D;0000007208;;20080401;3;0;0;3;;B;ZZZZZZ; WT;T25D;0000007208;;20080401;6;0;0;6;;B;ZZZZZZ; WT;T5D;0000007208;;20080401;123;0;0;123;;B;ZZZZZZ; to WT;T15D;0000007208;;04/01/200804;3;0;0;3;;B;ZZZZZZ;... (2 Replies)
Discussion started by: svenkatareddy
2 Replies

2. Shell Programming and Scripting

How to Change the Format of a Date

Hi All, this is my second post, last post reply was very helpful. I have a data that has date in DD/MM/YYYY (07/11/2008) format i want to replace the backslash by a dot(.) so that my awk script can read it inside the C shell script that i have written. i want to change 07/11/2008 to... (3 Replies)
Discussion started by: asirohi
3 Replies

3. Shell Programming and Scripting

Date Format Change

Hi I have a date format in a variable as Mon Jan 11 03:35:59 2010. how do i change it to YYYYMMDD format (3 Replies)
Discussion started by: keerthan
3 Replies

4. Shell Programming and Scripting

Date Format Change

Hi, Please can I have some command to get yesterday in YYMMDD format? This will be used in ksh Thanks, (2 Replies)
Discussion started by: smalya
2 Replies

5. Shell Programming and Scripting

How to change the date format

Hi Guys, Can someone help me on how to change the date format using sed or any unix command to give my desired output as shown below. INPUT FILE: 69372,200,20100122T17:56:02,2 53329,500,20100121T11:50:07,2 48865,100,20100114T16:08:16,2 11719,200,20100108T13:32:20,2 DESIRED... (2 Replies)
Discussion started by: pinpe
2 Replies

6. Shell Programming and Scripting

Date format change

Dear Friends, Need your help once again, I have a variable ( e.g. ${i}) whoch has date in MM/DD/YYYY (E.g. 12/31/2011) format. I want to change it to DD/MM/YYYY (e.g. 31/12/2011) format. Request you to guide me as we are unable to do the same. Thanks in advance Anu. (1 Reply)
Discussion started by: anushree.a
1 Replies

7. Shell Programming and Scripting

Change the date format

Hi all, I have a file that every line starts with the date and time. The format is like YYYYMMDDHHMM and I woulk like to change it to MM/DD/YY<space>HH:MM. I tried to figure out a way to do it with sed, but I don't know how I could reorganize the digits of the first format. Does anyone have any... (1 Reply)
Discussion started by: geovas
1 Replies

8. Shell Programming and Scripting

Change the date format

Hi, I was looking for a script to change the date from one format to other. A search in the forum gave me the below script as a result. #! /bin/ksh format=YYYYMMDD YEAR=${format%????} DAY=${format#??????} MON=${format#$YEAR} MON=${MON%$DAY} echo $MON/$DAY/$YEAR I got it... (2 Replies)
Discussion started by: prithvirao17
2 Replies

9. Shell Programming and Scripting

Need to change date format in a csv file using awk

Example: Input csv file 00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00 00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00 Output csv file 00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel... (8 Replies)
Discussion started by: adit
8 Replies

10. UNIX for Beginners Questions & Answers

Date format conversion how to change this from using nawk to awk

Hi, I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk. Test run as below: $: cat xyz.txt A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
MIME::Field::ParamVal(3pm)				User Contributed Perl Documentation				MIME::Field::ParamVal(3pm)

NAME
MIME::Field::ParamVal - subclass of Mail::Field, for structured MIME fields SYNOPSIS
# Create an object for a content-type field: $field = new Mail::Field 'Content-type'; # Set some attributes: $field->param('_' => 'text/html'); $field->param('charset' => 'us-ascii'); $field->param('boundary' => '---ABC---'); # Same: $field->set('_' => 'text/html', 'charset' => 'us-ascii', 'boundary' => '---ABC---'); # Get an attribute, or undefined if not present: print "no id!" if defined($field->param('id')); # Same, but use empty string for missing values: print "no id!" if ($field->paramstr('id') eq ''); # Output as string: print $field->stringify, " "; DESCRIPTION
This is an abstract superclass of most MIME fields. It handles fields with a general syntax like this: Content-Type: Message/Partial; number=2; total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" Comments are supported between items, like this: Content-Type: Message/Partial; (a comment) number=2 (another comment) ; (yet another comment) total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" PUBLIC INTERFACE
set [\%PARAMHASH | KEY=>VAL,...,KEY=>VAL] Instance method. Set this field. The paramhash should contain parameter names in all lowercase, with the special "_" parameter name signifying the "default" (unnamed) parameter for the field: # Set up to be... # # Content-type: Message/Partial; number=2; total=3; id="ocj=pbe0M2" # $conttype->set('_' => 'Message/Partial', 'number' => 2, 'total' => 3, 'id' => "ocj=pbe0M2"); Note that a single argument is taken to be a reference to a paramhash, while multiple args are taken to be the elements of the paramhash themselves. Supplying undef for a hashref, or an empty set of values, effectively clears the object. The self object is returned. parse_params STRING Class/instance utility method. Extract parameter info from a structured field, and return it as a hash reference. For example, here is a field with parameters: Content-Type: Message/Partial; number=2; total=3; id="oc=jpbe0M2Yt4s@thumper.bellcore.com" Here is how you'd extract them: $params = $class->parse_params('content-type'); if ($$params{'_'} eq 'message/partial') { $number = $$params{'number'}; $total = $$params{'total'}; $id = $$params{'id'}; } Like field names, parameter names are coerced to lowercase. The special '_' parameter means the default parameter for the field. NOTE: This has been provided as a public method to support backwards compatibility, but you probably shouldn't use it. parse STRING Class/instance method. Parse the string into the instance. Any previous information is wiped. The self object is returned. May also be used as a constructor. param PARAMNAME,[VALUE] Instance method. Return the given parameter, or undef if it isn't there. With argument, set the parameter to that VALUE. The PARAMNAME is case-insensitive. A "_" refers to the "default" parameter. paramstr PARAMNAME,[VALUE] Instance method. Like param(): return the given parameter, or empty if it isn't there. With argument, set the parameter to that VALUE. The PARAMNAME is case-insensitive. A "_" refers to the "default" parameter. stringify Instance method. Convert the field to a string, and return it. tag Instance method, abstract. Return the tag for this field. SEE ALSO
Mail::Field perl v5.14.2 2012-06-08 MIME::Field::ParamVal(3pm)
All times are GMT -4. The time now is 11:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy