cancel
Showing results for 
Search instead for 
Did you mean: 

script wanted

 
Highlighted
New Member

script wanted


I have a database log ( db.log ) which the messages will be appended to it , some of the messages is non-useful , so I want to write a script to write all the lines that have the message "warning" to another log ( eg. db.log2 ), and then remove this line in db.log , as below example , can advise what can i do ? Thanks.


The log is as below
===================
#vi db.log

"
aaa
bbb
ccc
warning 111
ddd
eee
warning 222
fff
"

 

run the script , the desired output is as below
===============================================
#vi db.log
aaa
bbb
ccc
ddd
eee
fff


#vi db.log2
warning 111
warning 222

2 REPLIES 2
Highlighted
Honored Contributor

Re: script wanted

Do you have to remove them?
Would it be OK to get 'more' log files?

cp db.log db2.log
grep 'warning' db2.log > db.error.log
grep -v 'warning' db2.log > db.info.log
Highlighted

Re: script wanted

This is the wrong category for scripting.

What OS are you running?  What command/shells are available?