Click to See Complete Forum and Search --> : Retriving a particular line
akshayjohari
08-20-2007, 01:59 AM
Hi,
Can anyone knows how can I retrieve a particular line from a file.
Basically, I wanna fetch some lines from SYSLOG-NG. It has all the log of servers. There are some files like: cron.info , mail.info etc. and cron.warning, mail.warning etc. I wanna retrieve the lines that has "*.warning".
Can anyone plzs tell me how can I do that.
Thanks
saikee
08-20-2007, 05:52 PM
akshayjohari ,
Welcome to JustLinux.
I don't write many scripts and wouldn't know enough to do your task with Bash. However I am sure Python can eat it for breakfast as it has a good set of the string handling functions. As you can execute a Python script same as a Bash script so my suggestion is to try it out. Python is shipped as a standard feature in most of the Linux I come across.
Asking people to Write a script can run into a funny reception as many forum members are reluctant to help thinking they are conned into doing homework for a student. Therefore it would help your case if you build part of it, to show you have tried but got stuck, and show us your input data, say in truncated form.
DrChuck
08-20-2007, 09:04 PM
You could also do this with grep. Here is how I would test one file:
grep -H ".warning" mail.info
You may want to add some more options ( see the grep man page ), and wrap a script around it to cover all the files you are interested in.
drChuck