I got stuck in processing a log file wherein I need to spilt an application directory name from the log file. Below are the log files
.
The name of the log files consisting of the application name, like TIL_MQSI_EPOSAdapters and the engine name TIL_MQSI_EPOSAdapters-RetailSystemsMQAdapter saparated by a "." or a "-".
I need to split the application name and the engine name out of these log files. As you can see the application name and the engine name in the log file are almost same.
My desired output is
Can you please let me know how this can be achieved?
The issue is that, the Fields are always not the same due to the invariable name of log files. So even we print the col1 and col2, it will not give us the desired result always. Like in the following case
What I am looking for is compare the value of col1 to the rest of the cols in a log file and if it matches, then print from col1 upto one col less than the matched col,as the application name.
Like,
Here, col1=SalesAndMarketing, col2=Misc, col3=1,col4=SalesAndMarketing
and col5=Misc.
As you can see, col1 and col4 have the same value, so the desired output would be; SalesAndMarketing-Misc-1(col1, col2, col3).
Just for your information, the application name and the engine name will always be the same except that an integer in the app name sometimes.
Please let me know your thoughts.
Thanks,
Chandan
Last edited by singh.chandan18; 07-16-2010 at 01:25 PM..
Reason: corrected the mistakes.
I've tried lots of tricks, but none of them is working. So, Need help from t he Experts.
Here is my problem,
I have Log files and I need to extract App Directory name from them.
The name of the log file is the combination of the App Dir name and the App Engine name.
Both the App Dir name and the Engine name are almost same. But, there is no consistiency in the naming convention of the log file which is creating the issues.
One way to solve the problem is using awk and match the first field with the rest of the fields in a record.
If the match is found, print all the fields from the first upto the field one less than the matched field.
Can you please suggest if this can be done using awk? or, is there any other way?
I've found the solution for this as below:
Splitting the elements of the filename into an array. Then loop through each element - if it doesn't match the first element, concatenate it to a variable holding the directory name. If the element matches the first one, print out the directory name.
Hi,
My file is seperated with ";" delimiter, after 13 delimiter i want to put the data in new line...
eg:
My current file:-
a;b;c;d;e;f;g;h;e;f;h;s;t;a;i;o;q;t;q;r;yu;f;sz;f;t;r...........
i want o/p as:-
a;b;c;d;e;f;g;h;e;f;h;s;t
a;i;o;q;t;q;r;yu;f;sz;f;t;r
How to achieve ths,... (2 Replies)
A text file has 2 fields (Data, Filename) delimited by # as below,
Data,Filename
Row1 -> abc#Test1.xml
Row2 -> xyz#Test2.xml
Row3 -> ghi#Test3.xml
The content in first field has to be written into a file where filename should be considered from second field.
So from... (4 Replies)
Hello,
For the input file, I am trying to split those records which have multiple values seperated by '|' in the last input field, into multiple records and each record corresponds to the common input fields + one of the value from the last field.
I was trying with an example on this forum... (4 Replies)
Hello gurus,
I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files.
e.g. my data is like:
Row_Num,... (6 Replies)
Hi everyone.
I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this:
ID: 20
Name: X
Age: 19
ID: 21
Name: Z
ID: 22
Email: xxx@yahoo.com
Name: Y
Age: 19
I want to grep records that... (4 Replies)
Hi All,
I have two files say file1 and file2.
I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions .
Could you pls... (3 Replies)
All,
We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g.
File1:
UHDR 2008112
"25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ... (2 Replies)
I have a flat file and need to count no of records in the file less the header and the trailer record.
I would appreciate any and all asistance
Thanks
Hadi Lalani (2 Replies)