Computing.Net > Forums > Unix > AWK,grep,cut log files

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

AWK,grep,cut log files

Reply to Message Icon

Original Message
Name: merouane
Date: August 17, 2005 at 15:12:09 Pacific
Subject: AWK,grep,cut log files
OS: WIN32 (Cygwin)
CPU/Ram: w
Comment:

Dear all.

I want to achieve the following:

1/grep all the lines starting with id 35.64 for example, from a log file:

grep [3][5][.][6][4] file.log

result:

35.64 325323666 20050818
35.64 325325666 20050818
35.64 325327666 20050818
35.64 325328666 20050818


2/Once I get all the lines, parse them and fill values in a chart:


id user SID timestamp
-----*-----*----*----------*
35.64 325323 666 20050818
35.64 325325 666 20050818
35.64 325327 666 20050818
35.64 325328 666 20050818


Would also be nice to be able to sort the fields by timestamp or user/

Thanks for any input@

merou


Report Offensive Message For Removal


Response Number 1
Name: vicchai
Date: August 18, 2005 at 07:48:16 Pacific
Reply:

Hi,

Try this:

echo "id user SID timestamp" > output.txt
echo "==== ==== ==== =======" >> output.txt
grep ^35.64 file.log | sort -t 4 >> output.txt


Report Offensive Follow Up For Removal

Response Number 2
Name: merouane
Date: August 21, 2005 at 02:38:13 Pacific
Reply:

Thanks Vicchai,

But how do I deal with records that i want to split (space as delimiter) but belong to the same column:

Example:

from there:
35.64 325323666 20050818

to there:
35.64 325323 666 20050818

I was thinking of using the substr function in awk, but maybe there is something more simple.

Thanks.


Report Offensive Follow Up For Removal

Response Number 3
Name: merouane
Date: August 21, 2005 at 07:19:42 Pacific
Reply:

Even substr is no good, because it is dealing with columns.

I just want a function that split a string(record), and I specify how I want to split it.

example:

0-5 : ID
6-12 : user
.......
.......

Thanks.


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home



Results for: AWK,grep,cut log files

How to call other shell/awk script
    Summary: maybe better if I describe my awk script : inside my awk script like this, ... /error/ { NR == lineErr } NR == lineErr { `showErrMessage` } ... In this awk script I tried to grep from log files any er...
www.computing.net/answers/unix/how-to-call-other-shellawk-script-/5571.html

scan log file by a search string
    Summary: ***Begin Script*** #!/bin/ksh #delete file created by the grep command (start fresh) rm /path/filename #error checking if [ $# -eq 0 ] then echo "Usage is: $0 logfile error_mes...
www.computing.net/answers/unix/scan-log-file-by-a-search-string/8153.html

erro-log file
    Summary: I have a SunOS 5.7 and 3 PC that with W2K that telnet to the Server i've been losing my telnet sessions, for the past three days, it's like on and off, and i'm trying to determin what wrong, is it m...
www.computing.net/answers/unix/errolog-file/3276.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software