csv file field needs to be changed current system date with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting csv file field needs to be changed current system date with awk
# 1  
Old 08-18-2011
csv file field needs to be changed current system date with awk

HI,

I have csv file with records as shown below.

HTML Code:
4102,Bangalore,G10,21,08/17/2011 09:28:33:188,99,08/17/2011 09:27:33:881,08/17/2011 09:27:39:22,1580807561,404450302456086,919740330452,3553100467504101,2,NULL,NULL,Ericsson-South_Central,122.170.0.129,airtelgprs.com,404,45,16274,255,443,223.177.40.84,74.125.236.81,443,881,67,3522,2210,11,12,1,1,870,2284,5141,0,443,1,5,1580807561,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,27043,NULL,
here fifth $5 field is some date and time say 08/17/2011 09:28:33:188

i want to change that field with current system date and time for all the records.ate time is
say current system date 08/18/2011 15:14:57:188

any thought with awk ?

Thanks,
Raghavendra
# 2  
Old 08-18-2011
Code:
awk -v dat=$(date +%d/%m/%Y) -v tim=$(date +%H:%M:%S) '{$5=dat" "tim}1' FS=, file

Guru.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date not correct so it changed to current date.

Hello, so basically i have a txt file containing "foto's" named YYYY-MM-DD_HH.mm.ss.jpeg. But since it can probably not convert it it changes the date to the current date. What am i doing wrong? #!/bin/bash inputDateFmt() { sed -e 's/_/ /g' -e 's/\./:/g' <<< "$1" } begindatum=$(date... (3 Replies)
Discussion started by: Rovester
3 Replies

2. Shell Programming and Scripting

awk - CSV file - field with single or multiple spaces

Hi, In a csv file, I want to select records where first column has zero or multiple spaces. Eg: abc.csv ,123,a ,22,b ,11,c a,11,d So output should be: ,123,a ,22,b ,11,c Please advise (5 Replies)
Discussion started by: vegasluxor
5 Replies

3. 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

4. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

5. UNIX and Linux Applications

Reflection Macro: Use Current Date Information in specific field of report

Hi Everyone, New to the forum, and have my first question. I have the following Macro currently being used within Telnet to run a report for the date being entered. However, now I need the Macro to input the day after today to the the day after today. Example: If today is May 9, 2012 - the... (0 Replies)
Discussion started by: CipherEffect
0 Replies

6. UNIX for Dummies Questions & Answers

Comparing Output Date to Current System Date

Hi Guys, Anyone who knows how to compare the current date with the a file containing a date, say for example I have a file that looks like this: Command was launched from partition 0. ------------------------------------------------ Executing command in server server6 Fri Dec 16... (7 Replies)
Discussion started by: rymnd_12345
7 Replies

7. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

8. Shell Programming and Scripting

how to get what date was 28 days ago of the current system date IN UNIX

Hi, Anybody knows how to get what date was 28 days ago of the current system date through UNIX script. Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Discussion started by: kandi.reddy
15 Replies

9. UNIX for Dummies Questions & Answers

get current system date

How do I create a shell script that would get the current system date in format of yyyymmdd and use that result to concatenate it to a filename that it would look like this: sample20051024.dat example -------- current system date: 24-Oct-2005 filename: sample.dat when the shell script... (5 Replies)
Discussion started by: wtolentino
5 Replies

10. UNIX for Dummies Questions & Answers

I want to get day from the current system date

Hi, I want to check what day is today (like mon,Tue,wed) When i checked the syntax, i dont see there is a format specifier for getting the day. Let me know how to get the same. I am very new to unix and so I am asking some basic questions. cheers, gops (2 Replies)
Discussion started by: gopskrish
2 Replies
Login or Register to Ask a Question