Operating System - HP-UX
1833758 Members
2562 Online
110063 Solutions
New Discussion

Need a Script to strip out id # - HP 11.0

 
SOLVED
Go to solution
Laurie_2
Advisor

Need a Script to strip out id # - HP 11.0

Hi All,

I have a student access log that I need to
strip out the student id #. Here's a sample of
the log file:

38.164.211.67 - 411188 [13/May/2002:10:29:39 -0500] "GET /cgi-bin/student/register/me
nu.cgi HTTP/1.1" 200 1619
12.34.246.5 - 395630 [13/May/2002:10:29:43 -0500] "GET /cgi-bin/student/menu.cgi HTTP/
1.0" 200 2868
205.188.209.10 - 376553 [13/May/2002:10:29:46 -0500] "GET /cgi-bin/student/menu.cgi HT
TP/1.0" 200 2869

I want a script (I prefer c shell) to for
for ' - ' and then give me the next 6 characters which should always be numeric and
I want to just save the id #'s to an ascii
file.

So for the above log I want this output:

411188
395630
376553

I want it to search till it hits an end of
file. This script will run daily.

Then I will take the student id #'s and read a table (another script) to find out what site they are from and then I will write a report.

TIA,
Laurie

How can you make the world a better place
3 REPLIES 3
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Need a Script to strip out id # - HP 11.0

perl -nle '/ - (\d+)/&&print$1' logfile
Enjoy, Have FUN! H.Merijn
John Carr_2
Honored Contributor

Re: Need a Script to strip out id # - HP 11.0

Hi

one simple command wil do it

cat filename | awk '{ print $3}'

this takes the space as the delimeter which exists after the - and after the student number.
cheers
John.
John Carr_2
Honored Contributor

Re: Need a Script to strip out id # - HP 11.0

Hi

/usr/bin/csh
cat filename | awk '{ print $3}'
exit