Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help parsing log file

Status
Not open for further replies.

moepower

Programmer
Oct 5, 2000
93
US
I need to parse some information out of a log file on a daily basis and insert it into an Oracle table. I'm very new to UNIX scripting so the more details you can provide the better. ie.

LogFile
1242 34328 300989880 bkwe 0001 20020212
1242 300989880 bkwe 0002 20020212
1242 348 9880 acb bkwe 0003 20020212

I need the information from the first, second, and last field on the second line which would be 1242, 300989880, 20020212 insert into an Oracle table.

Thank you,
Moe
 
To pull just certain columns of info, use this:

cat ${FILE} | /usr/bin/awk '{print $1, $3, $6}'

${FILE} == Database

$1 == Column 1
$3 == Column 3
$6 == Column 6
etc.
 
Moe:

two things:

1) First, there's nothing wrong with the script, provided the last field is always the 6th; It it's not, do this:

awk '{print $1, $3, $NF}'

where NF is the number of fields.

2) If you're going to insert this into an Oracle table, you need to use sqlplus. Not being an Oracle person, I can't help you, but Mike Lacey's FAQ can:

FAQ759-2221

Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top