blaaze
Thank you for your replay. Unfortunately I will not be able to provide the files (proprietary).
Main Topics
Browse All TopicsI have a log files containing several thousand lines.
At the bottom of every log file there are four or five lines formated as following:
Amountname1: 1299
Amountname2: 434
Amountname3: 0
Amountname4: 14
Amountname5: 1007
I need to be able to run a cron job and read last lines with amounts to get output to csv file, something like this:
1299,434,0,14,1007
Thank you for your help.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I assume, that your log files have .log extension, and you are running this script in directory in which there are these log files.
Script takes last 4 lines and writes them to file.csv.
If your files can have sometimes 5 lines, you have to be more specific about these 4/5 lines. What is the difference between last four lines, and fifth from the end (or last five and sixth from the end)? Should script determine automatically if it should take 4 or 5 lines, or this should be specified once by you?
Strange; here is the result I am getting from both, omarfarid and oklit solution.
,7652
It looks like it is reading last digits. Does this have anything with spaces between amount number and amount name or log file format itself - number of spaces can be different?
Amount1: 2000
Amount2: 672
Amount35: 0
Amount4: 1252
Amount55: 76
If I manually create sample log file for testing than everything works fine.
Ok, here is the format of the log files. So I need to read last five lines only and take the numbers.
AAA A,253698517,621459,,445563
BBB B,253698517,621459,,445563
CCC A,253698517,621459,,445563
DDD D,253698517,621459,,445563
EEE E,253698517,621459,,445563
xxxxxxxxx: 2000
xxxxx: 672
xxxxxxx: 0
xxxxxxx: 1252
xxxxxxxx: 76
Thank you!
here the results of my script:
$ cat rr
AAA A,253698517,621459,,445563
BBB B,253698517,621459,,445563
CCC A,253698517,621459,,445563
DDD D,253698517,621459,,445563
EEE E,253698517,621459,,445563
xxxxxxxxx: 2000
xxxxx: 672
xxxxxxx: 0
xxxxxxx: 1252
xxxxxxxx: 76
$ cat tt
set `tail -5 rr | awk -F: '{ print $2 }'`
echo $1 , $2 , $3 , $4 , $5
$ sh tt
2000 , 672 , 0 , 1252 , 76
Business Accounts
Answer for Membership
by: blaazePosted on 2009-06-16 at 06:05:42ID: 24637501
can u send me sample files so that i can get the script