filtering the log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting filtering the log file
# 1  
Old 06-13-2011
filtering the log file

Hi i have a log file like example below.

I need only one field from below log [8AC1178C859113944F130797425349430] all other need to be truncated from the log file.

2011-06-13 15:10:53,498 INFO [8AC1178C859113944F130797425349430] [com.tmobile.ei.sbp.cal.logging.LMSHelper] ext.SP->CAL (log point 5)

can any body help on this please.

Thanks
# 2  
Old 06-13-2011
Code:
cut -d\[  -f2 <file.log| cut -d \] -f1
OR 
awk -F'\[' '{print "["$2}' file.log

Update Doh, Corona's solution below is much neater, though the cut could be updated to
Code:
cut -d\  -f4 <file.log


Last edited by Skrynesaver; 06-13-2011 at 12:31 PM..
# 3  
Old 06-13-2011
awk '{ print $4; }' < filename
# 4  
Old 06-13-2011
Like this?
Code:
sed 's/.* \(\[[^ .]*\]\) .*/\1/' logfile

This will grab the field in brackets with no spaces or dots inside.
# 5  
Old 06-13-2011
Quote:
Originally Posted by Corona688
awk '{ print $4; }' < filename
This one works like a charm.. is there any output will send to another file.

Thank you very much.

---------- Post updated at 10:52 AM ---------- Previous update was at 10:39 AM ----------

Quote:
Originally Posted by mostwantedkisss
This one works like a charm.. is there any output will send to another file.

Thank you very much.

Thanks
I have moved output to file using redirection.... >>
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with filtering records in a file

Hi, I have following records in a file more file1.txt setting applicaction ABC for user setting applicaction CDE for user setting applicaction XXX for user logging applicaction XXX for user I need to filter out records which have strings " setting... (5 Replies)
Discussion started by: manid
5 Replies

2. Shell Programming and Scripting

Filtering log file with lines older than 10 days.

Hi, I am trying to compare epoch time in a huge log file (2 million lines) with todays date. I have to create two files one which has lines older than 10 days and another file with less than 10 days. I am using while do but it takes forever to complete the script. It would be helpful if you can... (12 Replies)
Discussion started by: shunya
12 Replies

3. Shell Programming and Scripting

PERL "filtering the log file removing the duplicates

Hi folks, I have a log file in the below format and trying to get the output of the unique ones based on mnemonic IN PERL. Could any one please let me know with the code and the logic ? Severity Mnemonic Log Message 7 CLI_SCHEDULER Logfile for scheduled CLI... (3 Replies)
Discussion started by: scriptscript
3 Replies

4. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

5. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

6. Shell Programming and Scripting

filtering the rows in a file

hi all, please help on this isssue, i have a file which contains something like this and i want to seprate the servers which has vasd.pid ,i need only server names. i want output something like this which vasd.pid . server1 server3 server4 (4 Replies)
Discussion started by: sudharson
4 Replies

7. UNIX for Dummies Questions & Answers

Filtering a file

I have a list of directories looking something like; /usr/local/1/in /usr/local/1/out /usr/local/1/archive /usr/local/2/in /usr/local/2/out /usr/local/2/archive /usr/local/3/in /usr/local/3/out /usr/local/3/archive Is there a way I can filter the out and archive directories so I... (5 Replies)
Discussion started by: JayC89
5 Replies

8. Shell Programming and Scripting

Filtering the yesterdays date from log files via script.

hi All, I have this sample text file - access.log: Jan 18 21:34:29 root 209.151.232.70 Jan 18 21:34:40 root 209.151.232.70 Jan 18 21:34:43 root 209.151.232.70 Jan 18 21:34:56 root 209.151.232.70 Jan 18 21:35:10 root 209.151.232.70 Jan 18 21:35:23 root 209.151.232.70 Jan 18 21:36:04 root... (2 Replies)
Discussion started by: linuxgeek
2 Replies

9. UNIX for Dummies Questions & Answers

Filtering Log file

Hi, Iam trying to filter a log file in the below format |fffff|hhhhh|ffff|dd|mm|yy|hh|min||dd|mm|yy|hh|min the first set of |dd|mm|yy|hh|min is when the application ran the second set of |dd|mm|yy|hh|min when it ended. I will be removing the last of the months in the log file to... (1 Reply)
Discussion started by: baanprog
1 Replies

10. Shell Programming and Scripting

Filtering line out of file

Hy, I would like to extract lines within following file, 4TX + 4XFUT + 4XBACK + 4Xexp: theo. actual start of day: -2 5 end of day: 5 4 profit: 2 -1 ==================== trade profit: 9 -2... (9 Replies)
Discussion started by: sam786
9 Replies
Login or Register to Ask a Question