Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Scripting help, Removing everything from a log file before a character
jennyjebson
post Dec 3 2007, 06:49 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 30-November 07
Member No.: 13,168



Hello,

I am a newbie, and need a little assistance!

I have an application that is running on Linux that produces a log file.

The information in the log file is produced by purely enabling the debug option in the application, however there is far too much

non useful information in the log files produced.

I would like to cut out some of the information in the log file... there seems to be a unique character after which I think is useful information.

So I would like to remove all characters before this unique character on each line "|" and output this to a new log file.

Firstly, is this possible? as anyone able to help me make a little script?

Here is an excerpt from the the log file produced:

30-11 11:55:06 expect: Timeout(30) Max Len(60) EndLen(2) FailFlag(0) StartLen(0)
30-11 11:55:06 toggle_HUP: Hangup line
30-11 11:55:08 sending command:
0D 0A | ..

30-11 11:55:11 expect: Timeout Occured

30-11 11:55:11 main: Failed - Next Command = 10
30-11 11:55:11 expect: Timeout(10) Max Len(50) EndLen(0) FailFlag(0) StartLen(0)
30-11 11:55:14 sending command:
0D 0A 0D 0A | ....

30-11 11:55:15 expect: Timeout Occured

30-11 11:55:15 main: Success - Next Command = 50
30-11 11:55:15 expect: Timeout(40) Max Len(1600) EndLen(5) FailFlag(0) StartLen(4)
30-11 11:55:16 sending command:
0D 40 30 31 20 68 20 31 0D | .@01 h 1.

30-11 11:55:16 expect: Found Start String
30-11 11:55:16 expect Found Reply String (position 357) (minLen 0)
30 31 0D 0A 23 0D 0A 0D 0A 32 30 30 37 2D 31 31 | 01..#....2007-11
2D 32 38 20 20 32 33 3A 35 30 2C 30 31 2C 48 31 | -28 23:50,01,H1
34 2C 52 4F 53 41 0D 0D 0A 30 31 20 20 20 39 2E | 4,ROSA...01 9.
39 3B 30 32 20 20 20 20 37 37 3B 30 33 20 20 20 | 9;02 77;03

Is anyone able to help me?

Thanks,

jenny
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
markjr
post Jan 15 2008, 10:59 PM
Post #2


./configure
***

Group: Admin
Posts: 62
Joined: 9-February 06
Member No.: 6,054



From a command line I would do this:

CODE
grep \| <logfile> | cut -d\| -f2


The "cut" command gives you access to a given field -f separated by delimiter -d, your original post said <i>before</i> the | but the rest of the thread it seemed like you wanted everything after the |, hence the -f2 but if you really do want before, just use -f1

So this wouldn't happen in realtime but maybe you could redirect to a new file, run out of crontab or something


CODE
grep \| <logfile> | cut -d\| -f2 > <newlog>
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th November 2017 - 04:03 PM