Sponsored Content
Top Forums Shell Programming and Scripting Insert date/time in reoccurring blocks of lines Post 302570719 by whizzler on Friday 4th of November 2011 07:13:38 AM
Old 11-04-2011
Java Insert date/time in reoccurring blocks of lines

Hi folks,

I have a little problem, that is kinda bugging me Smilie ...

I have a logfile, that looks kinda "crippled" in the raw format ...
So far, I've managed, to get it in a format like this:
Code:
PRI_PTA01,2W,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2W,1080,1080,707,1,0,0,0,0,1006,0,0,0,698,0
AT01ATSCTABW2,2W,465,465,287,1,21,0,0,0,554,0,0,21,281,19
AT01ATDHTABW1,2W,93,93,23,1,31,0,0,0,67,0,0,31,15,24
AT01ATDHTAOG1,2W,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2W,186,186,9,0,17,0,0,0,73,0,0,17,6,12
AT01NATLLOOPOG1,2W,87,87,0,0,1,0,0,0,0,0,0,1,0,0
AT01NATLLOOPIC1,2W,87,87,1,0,0,0,0,0,0,0,0,0,0,0
PRI_PTA01,2W,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2W,1080,1080,181,0,0,0,0,0,559,0,0,0,179,0
AT01ATSCTABW2,2W,465,465,89,0,23,0,0,0,301,0,0,23,86,21
AT01ATDHTABW1,2W,93,93,21,3,22,0,0,0,18,0,0,22,17,19
AT01ATDHTAOG1,2W,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2W,186,186,5,0,13,0,0,0,68,0,0,13,5,10
AT01NATLLOOPOG1,2W,87,87,0,0,0,0,0,0,0,0,0,0,0,0
AT01NATLLOOPIC1,2W,87,87,0,0,0,0,0,0,0,0,0,0,0,0
PRI_PTA01,2W,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2W,1080,1080,117,0,0,0,0,0,131,0,0,0,116,0
AT01ATSCTABW2,2W,465,465,51,0,6,0,0,0,142,0,0,6,49,4
AT01ATDHTABW1,2W,93,93,12,0,11,0,0,0,2,0,0,11,12,8
AT01ATDHTAOG1,2W,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2W,186,186,13,0,12,0,0,0,74,0,0,12,13,9
AT01NATLLOOPOG1,2W,87,87,0,0,0,0,0,0,0,0,0,0,0,0
AT01NATLLOOPIC1,2W,87,87,0,0,0,0,0,0,0,0,0,0,0,0

Those are repetitive blocks for every hour ...
Now, my problem is to replace the "2W" accordingly with date and time, so that it may look like this:
Code:
PRI_PTA01,2011.09.02 00:00:00,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2011.09.02 00:00:00,1080,1080,707,1,0,0,0,0,1006,0,0,0,698,0
AT01ATSCTABW2,2011.09.02 00:00:00,465,465,287,1,21,0,0,0,554,0,0,21,281,19
AT01ATDHTABW1,2011.09.02 00:00:00,93,93,23,1,31,0,0,0,67,0,0,31,15,24
AT01ATDHTAOG1,2011.09.02 00:00:00,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2011.09.02 00:00:00,186,186,9,0,17,0,0,0,73,0,0,17,6,12
AT01NATLLOOPOG1,2011.09.02 00:00:00,87,87,0,0,1,0,0,0,0,0,0,1,0,0
AT01NATLLOOPIC1,2011.09.02 00:00:00,87,87,1,0,0,0,0,0,0,0,0,0,0,0
PRI_PTA01,2011.09.02 01:00:00,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2011.09.02 01:00:00,1080,1080,181,0,0,0,0,0,559,0,0,0,179,0
AT01ATSCTABW2,2011.09.02 01:00:00,465,465,89,0,23,0,0,0,301,0,0,23,86,21
AT01ATDHTABW1,2011.09.02 01:00:00,93,93,21,3,22,0,0,0,18,0,0,22,17,19
AT01ATDHTAOG1,2011.09.02 01:00:00,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2011.09.02 01:00:00,186,186,5,0,13,0,0,0,68,0,0,13,5,10
AT01NATLLOOPOG1,2011.09.02 01:00:00,87,87,0,0,0,0,0,0,0,0,0,0,0,0
AT01NATLLOOPIC1,2011.09.02 01:00:00,87,87,0,0,0,0,0,0,0,0,0,0,0,0
PRI_PTA01,2011.09.02 02:00:00,30,30,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATSCTABW1,2011.09.02 02:00:00,1080,1080,117,0,0,0,0,0,131,0,0,0,116,0
AT01ATSCTABW2,2011.09.02 02:00:00,465,465,51,0,6,0,0,0,142,0,0,6,49,4
AT01ATDHTABW1,2011.09.02 02:00:00,93,93,12,0,11,0,0,0,2,0,0,11,12,8
AT01ATDHTAOG1,2011.09.02 02:00:00,31,31,0,0,0,0,0,0,0,0,0,0,0,0
AT01ATKGTABW1,2011.09.02 02:00:00,186,186,13,0,12,0,0,0,74,0,0,12,13,9
AT01NATLLOOPOG1,2011.09.02 02:00:00,87,87,0,0,0,0,0,0,0,0,0,0,0,0
AT01NATLLOOPIC1,2011.09.02 02:00:00,87,87,0,0,0,0,0,0,0,0,0,0,0,0

Maybe I'm just too tired already, so any advice would be welcome, on how to get along with this Smilie ... Smilie

Thanks in advance for any help.

Last edited by Scott; 11-04-2011 at 08:23 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert Time and Date Stamp

I have a directory with following files in it ABC.000.DAT ABC.001.DAT ABC.002.DAT ABC.003.DAT I want to insert time and date stamp in file names like ABC.000.YYYYMMDDHHMM.DAT I able to insert the time and date stamp at the end of filename Kindly help (1 Reply)
Discussion started by: aajmani
1 Replies

2. UNIX for Dummies Questions & Answers

Insert date/time within a filename

Hi Guys, I need to script the renaming of files as followins: files: firstjd secondjo thirdjv My script needs to insert the date/time infront of the last 2 characters of the filenames above, any ideas greatly received :) the letters before the last 2 characters could change, I'm only... (7 Replies)
Discussion started by: cooperman
7 Replies

3. Shell Programming and Scripting

Delete blocks of lines from text file

Hello, Hello Firends, I have file like below. I want to remove selected blocks say abc,pqr,lst. how can i remove those blocks from file. zone abc { blah blah blah } zone xyz { blah blah blah } zone pqr { blah blah blah } (4 Replies)
Discussion started by: nrbhole
4 Replies

4. Shell Programming and Scripting

Delete Blank Lines Between DHCP Host Blocks

Hi All, I have a dhcpd.conf file that gets static hosts added and removed via a shell script. After sometime, there becomes huge gaps of space ( blank lines ) between each host block. I tried a couple of sed one-liners; but, I can't seem to get the output I'm looking for. Also, I would like... (4 Replies)
Discussion started by: cstovall
4 Replies

5. Shell Programming and Scripting

Find 5 lines and replace with 18 line in sql file where it contains multiple blocks.

My sql file xyz_abc.sql in this file there are multiple sql block in this block I need to find the following block rem Subset Rows (&&tempName.*) CREATE VIEW &&tempName.* AS SELECT * FROM &&tempName.* WHERE f is not null and replace with following code rem Subset Rows... (9 Replies)
Discussion started by: Zaheer.mic
9 Replies

6. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

7. Shell Programming and Scripting

shell script to remove all lines which exceeds a particular date & time

I have a text file which got 6th coloumn as date and 7th coloumn as time. The text contains data for last one week. I need to remove all the data whose date & time is after 03/08/2011 06:00:00 and save it on another file TEXT FILE ======== 6 dbclstr-b IXT_Web Memphis_Prod_SQL_Diff... (4 Replies)
Discussion started by: ajiwww
4 Replies

8. Shell Programming and Scripting

[uniq + awk?] How to remove duplicate blocks of lines in files?

Hello again, I am wanting to remove all duplicate blocks of XML code in a file. This is an example: input: <string-array name="threeItems"> <item>item1</item> <item>item2</item> <item>item3</item> </string-array> <string-array name="twoItems"> <item>item1</item> <item>item2</item>... (19 Replies)
Discussion started by: raidzero
19 Replies

9. Shell Programming and Scripting

Transpose lines from individual blocks to unique lines

Hello to all, happy new year 2013! May somebody could help me, is about a very similar problem to the problem I've posted here where the member rdrtx1 and bipinajith helped me a lot. https://www.unix.com/shell-programming-scripting/211147-map-values-blocks-single-line-2.html It is very... (3 Replies)
Discussion started by: Ophiuchus
3 Replies

10. Shell Programming and Scripting

Insert date/time header at top of file

I'm trying to take mrt output and put it at the top of a file along with the date and time. I was able to do it at the bottom of the file with the following printf "********** $(date) **********\n\n" >> $OUTPUT_PATH/$HOSTNAME mtr -r -w -c 10 $HOSTADDRESS >> $OUTPUT_PATH/$HOSTNAME printf... (2 Replies)
Discussion started by: kramer65
2 Replies
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy