Sponsored Content
Top Forums Shell Programming and Scripting DateTime Format Conversion in a File Post 302141046 by jim mcnamara on Wednesday 17th of October 2007 12:15:49 PM
Old 10-17-2007
One way:
Code:
#Present format is YYYY/MM/DD-HH24:MI:SS
#Required Format is MM/DD/YYYY HH24:MI:SS

awk -F, '{
           split($1,dateval, "-")
           split(dateval[1], date, "/");
           value=sprintf("%s/%s/%s %s",date[2],date[3],date[1],dateval[2])
           printf("%s",value)
           for(i=2; i<=NF;i++)
                {printf(",%s", $i)};
           printf("\n");
        }' filename

Code:
# output
10/15/2007 12:04:24,'CRLift','TH-42PX75U','BestBuy','W01P0207',22,15,'User1'
10/15/2007 12:04:26,'CRLift','TH-42PX75U','BestBuy','W01P0207',22,15,'User2'
10/15/2007 12:04:29,'CRLift','TH-42PX75U','BestBuy','W01P0207',22,15,'User3'
10/15/2007 12:04:22,'CRLift','TH-42PX75U','CircuitCity','W01P0207',22,15,'User1'
10/15/2007 12:04:34,'CRLift','TH-42PX75U','CircuitCity','W01P0205',22,15,'User2'
10/15/2007 12:04:45,'CRLift','TH-42PX75U','CircuitCity','W01P0206',22,15,'User3'
10/15/2007 12:04:25,'CRLift','TH-42PX75U','CircuitCity','W01P0202',22,15,'User4'

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Flat File Conversion Format

Hi all, I've a flat file in this format: = " Record 1 Field1 -> XXXX Field2 -> 9558 Field3 -> 55AA Record 2 Field1 -> YYYY Field2 -> 12345 Field3 -> aa23 " And i want to convert it to (4 Replies)
Discussion started by: Loobian
4 Replies

2. Shell Programming and Scripting

format conversion

Is there any direct way in shell to convert exponential to other formats. For example 1.5e-07 to 0.150u. Or does shell support this microns, nano meter notations? (1 Reply)
Discussion started by: abhijanvt
1 Replies

3. Shell Programming and Scripting

Datetime Format 'yyyymmddmiss' Calculation

Given a time format yyyymmddmiss 201007221403 How can I add or minus minutes such that it becomes 201007221348 when I minus away 15 minutes from the time? Also, given a time frame, let say 10 days, how do I check if a date 201006231403 that is not more than 10 days behind... (3 Replies)
Discussion started by: alienated
3 Replies

4. Ubuntu

Conversion of the format of a file in linux

How to convert a rtf file to a ttf file in ubuntu terminal? (2 Replies)
Discussion started by: poonam.gaigole
2 Replies

5. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

6. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

7. Shell Programming and Scripting

conversion of spaces into CSV format file

INput file attached in thread : Column widths at 24,73,82,87,121 characters (sed 's/./,/24;s/./,/73;s/./,/81;s/./,/87;s/./,/121;s/ *, */,/g' fixedinputfile >output.csv ). The client wants instead of hard coding the column widths as they are not fixed .he has given the hint stating that ( ... (3 Replies)
Discussion started by: sreenath1037
3 Replies

8. Shell Programming and Scripting

XML dateTime format in shell script

How can i frame current date & time in the xml standard dateTime format in shell script 2011-10-18T12:00:00.000000 I got up to the date format using the below code date '+%Y'-'%m'-'%d'T ---------- Post updated at 09:10 AM ---------- Previous update was at 08:53 AM ---------- ... (6 Replies)
Discussion started by: vel4ever
6 Replies

9. Shell Programming and Scripting

Date conversion from 24 hr format to 12 hr format

hi i want to convert date procured from sone operation which will be in 24hr format to 12 hr format displaying AM and PM # date -d @1362545068 Tue Mar 5 23:44:28 EST 2013 # this Tue Mar 5 23:44:28 EST 2013 i want to convert it so that output is as below Tue... (2 Replies)
Discussion started by: vivek d r
2 Replies

10. Shell Programming and Scripting

Format conversion

Can you help me get the desired output? Below is the input CONA= 0. 5. 10. 15. 20. 25. 30. 35. 40. 45. 50. 55. 60. 65. 70. 75. 80. 85. 90. 95. 100. 105. 110. PLANA= 0. 15. 30. 45. 60. 75. 90. 105. 120. 135. 150. 165. 180. ITABLE= 87.3 171.4 242.9 297.6 322.8 325.6 306.8 284.5 273.4 272.2 270.2... (6 Replies)
Discussion started by: Ravi S M
6 Replies
grep-changelog(1)					      General Commands Manual						 grep-changelog(1)

NAME
grep-changelog - print ChangeLog entries matching criteria SYNOPSIS
grep-changelog [options] [CHANGELOG...] DESCRIPTION
grep-changelog searches the named CHANGELOGs (by default files matching the regular expressions ChangeLog and ChangeLog.[0-9]+) for entries matching the specified criteria. At least one option or file must be specified. This program is distributed with GNU Emacs. OPTIONS
The program accepts unambiguous abbreviations for option names. --author=AUTHOR Print entries whose author matches regular expression AUTHOR. --text=TEXT Print entries whose text matches regular expression TEXT. --exclude=TEXT Exclude entries matching regular expression TEXT. --from-date=YYYY-MM-DD Only consider entries made on or after the given date. ChangeLog date entries not in the "YYYY-MM-DD" format are never matched. --to-date=YYYY-MM-DD Only consider entries made on or before the given date. --rcs-log Print output in a format suitable for RCS log entries. This format removes author lines, leading spaces, and file names. --with-date In RCS log format, print short dates. --reverse Show matches in reverse order. --version Display version information. --help Display basic usage information. COPYING
Copyright (C) 2008, 2009 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this document provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this document under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this document into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. grep-changelog(1)
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy