Sponsored Content
Top Forums Shell Programming and Scripting Most vexing: Sed or Awk scripting for date conversion needed Post 302554655 by durden_tyler on Monday 12th of September 2011 01:54:07 PM
Old 09-12-2011
Using Perl -

Code:
$
$ cat csv.txt
"104787","MILLER,BOB M.","","Automatic refund. Expected over-payment","67.47","A","225","","128110048","1/8/2011 15:14:20"
"104196","REBECCA M MANNERS","","Automatic refund. Expected over-payment","53.21","A","225","","128110047","12/28/2011 15:14:20"
"104415","LEMMING,LETTUCE","","Automatic refund. Expected over-payment","257.03","A","225","","128110046","7/22/2011 15:14:20"
"104535","BUYTRON, LATOYA","","Automatic refund. Expected over-payment","281.51","A","225","","128110045","10/13/2011 15:14:20"
"104698","Jesus Rodriguez","Chase Bank","Prorate for december. 512-784-2711","200.00","N","225","","128110049","12/25/2011 15:14:20"
$
$
$ perl -ne 'chomp;
            m|^(.*)\b(\d+)/(\d+)/(\d+)\b(.*)$|;
            printf ("%s%04d-%02d-%02d%s\n", $1,$4,$3,$2,$5)
           ' csv.txt
"104787","MILLER,BOB M.","","Automatic refund. Expected over-payment","67.47","A","225","","128110048","2011-08-01 15:14:20"
"104196","REBECCA M MANNERS","","Automatic refund. Expected over-payment","53.21","A","225","","128110047","2011-28-12 15:14:20"
"104415","LEMMING,LETTUCE","","Automatic refund. Expected over-payment","257.03","A","225","","128110046","2011-22-07 15:14:20"
"104535","BUYTRON, LATOYA","","Automatic refund. Expected over-payment","281.51","A","225","","128110045","2011-13-10 15:14:20"
"104698","Jesus Rodriguez","Chase Bank","Prorate for december. 512-784-2711","200.00","N","225","","128110049","2011-25-12 15:14:20"
$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed - Replacing all date & time occurrences in a file with a string using Sed

Hi, I am new to using Sed. I have a file containg lines like the following: INFORM----Test.pc:168:10/11/05 12:34:26 > some text goes here.. TRACE-----Test.pc:197:10/11/05 12:34:26 > some text goes here.. My requirement is to replace 10/11/05 12:34:26 with a string <RUNDATE> (including <... (4 Replies)
Discussion started by: Hema_M
4 Replies

2. Shell Programming and Scripting

awk script for date conversion

hi awk script for dd/mm/yyyy to yyyymmdd awk script for dd-mon-yyyy to yyyymmdd awk script for dd-mm-yyyy to yyyymmdd formate ..............urgent............. Thanks in advanced (2 Replies)
Discussion started by: charandevu
2 Replies

3. Shell Programming and Scripting

sed or awk scripting help needed

hi all, for an example : df -k output shows: $ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p6 3099260 1117760 1824068 8% / /dev/cciss/c0d0p1 256666 18065 225349 8% /boot none 8219180 0 8219180 0% /dev/shm /dev/mapper/vglocal-home 1032088 245172 734488 26%... (7 Replies)
Discussion started by: raghur77
7 Replies

4. Shell Programming and Scripting

sed/shell scripting - add line if needed and not allready there

I am writing a shell script that checks all .c files to see if they use fprintf or printf. If a file does, then the line #include <stdio.h> is added to the top of the file, unless it's already there. This is what I've got: #!/bin/sh egrep -l f?printf *.c | while read file; do sed -i '1i\... (2 Replies)
Discussion started by: computethis
2 Replies

5. Shell Programming and Scripting

Wiki conversion with Awk or Sed

I have the words in twiki format that I want to convert to mediawiki format like below : %BLUE%some words1%ENDCOLOR% bla bla blab labdad sdadasd adsasdads oerdkfj kdfjs %PINK%some wordks2 123.4.5.6/26%ENDCOLOR%, ksdjak dkasjd kjfrjkfgjdkfgjdfkgjdgdfgdgf %PURPLE%1.2.3.4/28%ENDCOLOR%, dskd... (3 Replies)
Discussion started by: rk4k
3 Replies

6. Shell Programming and Scripting

help needed using awk scripting

Hi, I've few files in the following format file 1 ------------------------- A=a1 B=0 C=1 D=3 A=a2 B=0 C=1 D=3 A=a3 B=0 C=6 D=7 A=a4 B=0 C=1 D=3 A=a5 B=0 C=1 D=3 file 2 ------------------------- A=a1 B=2 C=2 D=4 A=a2 ... (2 Replies)
Discussion started by: skpvalvekar
2 Replies

7. UNIX for Advanced & Expert Users

Date Conversion on output string from awk

Hi, I would like to convert the output from awk function to date and print on the screen. Example : echo "Start Date: May 24 2010" | gawk -F": " '{print $2}' Output : May 04 2010 I want this to be converted to 2010/05/24 Can i use date function here and how? Thanks, Deepika (2 Replies)
Discussion started by: deepikad
2 Replies

8. Shell Programming and Scripting

another vexing awk problem

Hello; I have the following commnad: ls -lrt /ulogs/dblocks_logs/*log |awk '{print "grep Total "$9" |tail -20"}' | sh 05/10/11 21:54:01 Total number of locks:0 05/10/11 21:55:01 Total number of locks:0 05/10/11 21:56:01 Total number of locks:2 05/10/11 21:57:00 Total number of... (8 Replies)
Discussion started by: delphys
8 Replies

9. Shell Programming and Scripting

Bash Scripting with date format conversion

I have a script below and wanted to change the output into three different file format (3 separate script) #!bin/bash #input file format postwrf_d01_20131206_0600_f08400.grb2 #postwrf_d01_YYYYMMDD_ZZZZ_f0HHHH.grb2 #zzzz= 0000,0600,1200,1800 (in UTC) #HHHH=00000,00600,01200,01800 ..ect (in... (1 Reply)
Discussion started by: cumulus_255
1 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
get_midi_length(3alleg4)					  Allegro manual					  get_midi_length(3alleg4)

NAME
get_midi_length - Determines the total playing time of a midi, in seconds. Allegro game programming library. SYNOPSIS
#include <allegro.h> int get_midi_length(MIDI *midi); DESCRIPTION
This function will simulate playing the given MIDI, from start to end, to determine how long it takes to play. After calling this function, midi_pos will contain the negative number of beats, and midi_time the length of the midi, in seconds. Note that any currently playing midi is stopped when you call this function. Usually you would call it before play_midi, to get the length of the midi to be played, like in this example: length = get_midi_length(my_midi); play_midi(my_midi); do { pos = midi_time; textprintf_ex(screen, font, 0, 0, c, -1, "%d:%02d / %d:%02d ", pos / 60, pos % 60, length / 60, length % 60); rest(100); } while(pos <= length); RETURN VALUE
Returns the value of midi_time, the length of the midi. SEE ALSO
load_midi(3alleg4), midi_time(3alleg4), midi_pos(3alleg4), exmidi(3alleg4) Allegro version 4.4.2 get_midi_length(3alleg4)
All times are GMT -4. The time now is 11:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy