I am attempting to combine sections of log that should be one line but are spaced out over 10-30 lines due to how the software is outputting the info. (If I am making a newbie mistake I apologize)
Example of log I am working with:
2009-04-14 14:51:22 access data here
info.
Info.
Info.
…….. )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here data here
info.
Info.
Info.
data here )}
What is happening, is it is merging the lines as expected, but incorrectly merging the first line following the matched string.
I would expect the script to create two lines, one for each match of 2009-04, however what is being returned is:
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here info. info. info. data here. )} 2009-04-14 14:51:22 get data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
How do I stop the second matching line from being appended? Shouldn't it be on its own line since it is the next instance of 2009-04?
When I run the sed command the ouput still contains some unwanted newlines, this is the output after running the suggested command:
2009-04-14 14:51:22 access data here info. Info. Info. data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here Info. Info. Info. data here )}
What I need is:
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here. info. Info. Info. data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here )}
2009-04-14 14:51:22 access data here. info. Info. Info. data here )}
The purpose of all this is that its easier to merge files and sort once each line has a timestamp.
Edit: The only definate is that the lines I need to merge starts with 2009 and ends with )}
Using grep I can easily use:
cvs log |grep -iB 10 -A 10 'date: 2013-10-30'
to display search results and 10 lines before and after. How can this be accompished using gawk? (4 Replies)
Dear all,
I have a file like this:
imput
scaffold_0 1
scaffold_0 10000
scaffold_0 20000
scaffold_0 25000
scaffold_1 1
scaffold_1 10000
scaffold_1 20000
scaffold_1 23283
and I want the output like this:
scaffold_0 1 scaffold_0 10000
scaffold_0 10000 scaffold_0 20000... (6 Replies)
Hi,
I have a requirement like following:
I have input file like:
Question: 1 ----Multiple choice---
What is
your
favourite colour?
Options: a) red b) blue c) none of these
Question: 2 ---Multiple choice-----
In which month
did you join
your first job?
Options: a) Jan b) Feb c)... (11 Replies)
Hi all,
I have a text file consisting of 4 columns. What I am trying to do is see whether column 2 repeats multiple times, and collapse those repeats into one row. For example, here is a snippet of the file I am trying to analyze:
1 Gamble_Win 14.282 0.502
1 Sure_Thing 14.858 0.174
1... (4 Replies)
sir... am having a data file of customer master., containing some important fields as a set one line after another.,
what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed.
... (0 Replies)
Here is the sample file:
646 STARTED Tue Dec 30 06:38:53 2008
Job DdCustXAddr_brad has been reset.
647 STARTED Tue Dec 30 06:38:54 2008
Starting Job DdCustXAddr_brad. (...)
704 STARTED Tue Dec 30 06:49:02 2008
Job DdCustXAddr_brad aborted.
I want to combine every non-numbered line... (4 Replies)
Hi every body,
i have this file example :
TD1
TD2
TD3
.
.
.TDn
<DIE_1>
xxxxxx
<\DIE_1>
<TD1>
information 1
inormation n
<\TD1>
<TDq>
information (0 Replies)
hey,
I want to combine every three lines in a file onto one i.e
old file:
82 67 32
62 58 39
29 47 58
27 34 50
27 35 69
38 58 70
new file:
82 67 32 62 58 39 29 47 58
27 34 50 27 25 69 38 58 70
At the moment I am using the following code:
gawk 'BEGIN {x=0} { if(x<3)... (14 Replies)
Is there a way to combine two lines onto a single line...append the following line onto the previous line?
I have the following file that contains some blank lines and some lines I would like to append to the previous line...
current file:
checking dsk c19t2d6
checking dsk c19t2d7
... (2 Replies)
I am fairly new to scripting. But I have been able to extract and format all of my information required into one file. My issue is that one character is on a separate line. I need to be able to add the character to the previous line.
ex.
abcdefghi
1
bcdefghij
3
cdefghijk
4
need to... (4 Replies)