Visit Our UNIX and Linux User Community


Data sorting out from log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Data sorting out from log file
# 1  
Old 08-21-2013
Data sorting out from log file

I have a logfile looks like this:
Code:
 [2013-08-16 03:24:39,192][INFO ][AbstractServiceInvoker          [SID:187175558][] Received request of type [ReportNotification]

I need two write out every line to a new file if contains [INFO ] to a file called the SID name, like 187175558_xyz.txt

Thanks for helping!

---------- Post updated at 08:11 AM ---------- Previous update was at 08:10 AM ----------

I got this one liner:
Code:
awk -F'[]:]' '/INFO/ {print > ($6 "_xyz.txt")}' file

How can I do this in script file?
Thanks


Moderator's Comments:
Mod Comment Please use code tags for your code and data

Last edited by vbe; 08-21-2013 at 10:14 AM.. Reason: code tags!
# 2  
Old 08-21-2013
put
Code:
awk -F'[]:]' '/INFO/ {print > ($6 "_xyz.txt")}' $1

in a file, make it executable, and test... it need the filename fo argument ($1)
# 3  
Old 08-21-2013
Quote:
Originally Posted by vbe
put
Code:
awk -F'[]:]' '/INFO/ {print > ($6 "_xyz.txt")}' $1

in a file, make it executable, and test... it need the filename fo argument ($1)
The filename is newcs-in.log
# 4  
Old 08-21-2013
What I meant was using the script, you type
Code:
 scriptname filename

of course the output of your one liner would be STDOUT...
# 5  
Old 08-21-2013
Quote:
Originally Posted by vbe
What I meant was using the script, you type
Code:
 scriptname filename

of course the output of your one liner would be STDOUT...
Would be great that the output will be a file, every line that contains the INFO line must be in a file that named by the SID data, like this:

Code:
[2013-08-16 03:24:39,192][INFO ][AbstractServiceInvoker          [SID:187175558][] Received request of type [ReportNotification]

To a file named: 187175558_sid.txt

Other line line that contains INFO to a new file.
# 6  
Old 08-21-2013
Should work as is. Why don't you try and post the result?
# 7  
Old 08-21-2013
Quote:
Originally Posted by RudiC
Should work as is. Why don't you try and post the result?
Tried it. The result is 2 files with a lot of lines that contains the INFO message. That's not a problem. But i need every line that contains INFO message into a new file, that called by the actual line SID number.

Previous Thread | Next Thread
Test Your Knowledge in Computers #150
Difficulty: Easy
Oracle discontinued OpenSolaris after their acquisition of Sun Microsystems.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting data file by date and time

Hello. Sorting data file by date and time with the following issues: Date is in the following format m/d/yyyy, no leading zeros Time is in the following format h:m:s AM/PM, no leading zeros Any ideas on how to sort data when the above issues? Could the date/time be converted inline to... (5 Replies)
Discussion started by: JimBurns
5 Replies

2. Solaris

Monitoring log file for entries - Find command & sorting

hi, I would like to monitor a log file, which rolls over, everytime a server is restarted. I would like to grep for a string, and to be more efficient i'd like to grep only newly appended data. so something like a 'tail -f' would do, however, as the log rolls over i think a 'tail -F' is... (2 Replies)
Discussion started by: horhif
2 Replies

3. UNIX for Dummies Questions & Answers

Sorting data in file based on field in another file

Hi, I have two files, one of which I would like to sort based on the order of the data in the second. I would like to do this using a simple unix statement. My two files as follows: File 1: 12345 1 2 2 2 0 0 12349 0 0 2 2 1 2 12350 1 2 1 2 2 2 . . . File2: 12350... (3 Replies)
Discussion started by: kasan0
3 Replies

4. Shell Programming and Scripting

Sorting the Data

My actual data looks like below i have given only format. i can't give exact data format of my requirement due to some reasons. I this set of data lines about 5000 I need to come up with information in below exact format of my data set : Line<space>Number1<space>"somedata":... (1 Reply)
Discussion started by: ckaramsetty
1 Replies

5. UNIX for Dummies Questions & Answers

Help with Data Sorting

Hi All, I have a long list made of 4 columns containing entries such as the following example: a b c d 0 0 0 0 1 2 1 2 2 5 3 4 3 8 4 6 4 10 9 8 5 15 8 10So the top row is the header and I need to arrange the data in a way as to... (11 Replies)
Discussion started by: pawannoel
11 Replies

6. UNIX for Dummies Questions & Answers

Sorting data

Hello guys. I need help figuring this one out. It's probably really easy. Thanks in advance! I have a file say for example containing this: Rice Food Carrots Food Beans Food Plates Kitchen Fork Kitchen Knives Kitchen I need: Food Rice, Carrots, Beans Kitchen Plates, Fork,... (7 Replies)
Discussion started by: visuelz
7 Replies

7. UNIX for Dummies Questions & Answers

Sorting data from a to z

Hi, Let's say I have these 3 columns; NGC1234 6 9 SL899 4 1 NGC1075 8 3 SL709 5 2 And I want to sort the data according to the first column (from a to z) like having them as: NGC1075 8 3 NGC1234 6 9 SL709 5 2 SL899 4 1 Can that be done... (2 Replies)
Discussion started by: cosmologist
2 Replies

8. UNIX for Dummies Questions & Answers

Sorting data in an ASCII file

Hi,,, is there anyway to sort the data that I have on an ASCII file, using unix? :confused::confused::confused: Thanks (2 Replies)
Discussion started by: cosmologist
2 Replies

9. Shell Programming and Scripting

PERL data - sorting

Hello, I have a page where multiple fields and their values are displayed. But I am able to sort only a few fields. When I looked into the issue, it is seen that the for each row of info , an unique id is generated and id.txt is generated and saved. Only those fields which are inside that id.txt... (3 Replies)
Discussion started by: eagercyber
3 Replies

10. UNIX for Dummies Questions & Answers

sorting data from who by IP

Hello. I have an RS/6000 running AIX 4 and I need to be able to see if there are any users that are logged on more than once from the same terminal so I can kick them off to make room for other terminals. 64 connections is the limit. Currently I am doing this: who | more and then manually... (11 Replies)
Discussion started by: raidzero
11 Replies

Featured Tech Videos