help in sed script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help in sed script
# 8  
Old 07-04-2003
I`m not sure, but I found one file there`s so paragraph:
"Deleting Older Records from the Database
When the dbage function is run periodically, it should be run twice: once to delete
records for nonexistent conections with the -dd (dead data) option, and once to
force the deletion of outdated records.
For example, to delete dead data records and then delete report and raw data
records according to device definitions, enter the commands:
OLCmd dbage -n OracleStatsDB -dd
OLCmd dbage -n OraclStatsDB -d
The dbage function can be automated using cron under Solaris, or at under
Windows. See Rebuilding the Indexes on page 11 for a cron example.
For a complete description of the dbage command, see the OpenLane SLM
Administrator's Guide."
Maybe it could help?... Smilie
# 9  
Old 07-04-2003
But I am not deleteing anything from database !
I need to trim the logfile..
# 10  
Old 07-04-2003
A

As far as I can see you've got 2 problems
1) you must calculate the date on unix (not so easy)
By the way, how many days do you want to go back ?
You wrote "the backlog from some tables. Now that logfile is growing too big and I need to housekeep it! effectively I want to keep last 30 days data in that file and move rest to archived file.
The file contents are as below.
the algorithm I want is as follow :

take input file my.log
go to first line, check if this is more than 90 days
"
2) you must read your file line by line and act appropriatly.

I think I can find/make something that does the trick but, not in sed. Is regular korn shell ok for you ?
# 11  
Old 07-07-2003
All,
Out of woods finally !
Have a look at the code.
I got the date-90 in the required format from the sql itself :-)

and following is the korn code :
-------------------------------------------------------------------------------
DATE=`grep -v SQL /$HOME/dba/perfmon/siebel/date.lst | tail -2`
#this will get me line number of first occurence
grep -n $DATE mon_txn_rtr_backlog.log > /$HOME/dba/perfmon/siebel/tmp.log 2>&1
#Grep doesn't like my date parameter and might throw and error
#even if it's happy with that and deletes first 2 occurences, we run the script
#24 times a day so we are getting the correct date anyway!
sed "1,2 d" /$HOME/dba/perfmon/siebel/tmp.log > /$HOME/dba/perfmon/siebel/tmp1.l
og
LINE=`head -1 tmp1.log | cut -d":" -f2`
LINE=` expr $LINE - 1 `
if test $LINE != 0
then
# because we want to delete from 1 line early from first occurence
sed "1,$LINE d" /$HOME/dba/perfmon/siebel/mon_txn_rtr_backlog.log > /$HOME/dba/p
erfmon/siebel/mon_tmp.log
mv /$HOME/dba/perfmon/siebel/mon_tmp.log /$HOME/dba/perfmon/siebel/mon_txn_rtr_b
acklog.log
rm /$HOME/dba/perfmon/siebel/tmp.log
rm /$HOME/dba/perfmon/siebel/tmp1.log
fi
rm /$HOME/dba/perfmon/siebel/tmp.log
rm /$HOME/dba/perfmon/siebel/tmp1.log
-------------------------------------------------------------------------------

it works.

I still wonder how can I find out the date ( today-90 ) using shell !

Thanks anyway,
cheers
# 12  
Old 07-08-2003
All,
This may sound elementary but I am tired getting this at work!!
This piece of code is giving me a problem, in the sense when I run it manually it runs well, but when I run this though cron it gives me an error for expr syntax.

sed "1,2 d" /$HOME/dba/perfmon/siebel/tmp.log > /HOME/dba/perfmon/siebel/tmp1.log
LINE=`head -1 tmp1.log | cut -d":" -f2`
LINE=` expr $LINE - 1 `
if test $LINE != 0
then
.
.
.....

this `expr` is not running fine , can somebody please throw light on this please ? I know it all looks okay, but still ??
LINE=` expr $LINE - 1 `
# 13  
Old 07-08-2003
Inside your script, in between these two lines:

LINE=`head -1 tmp1.log | cut -d":" -f2`
LINE=` expr $LINE - 1 `

place a line that says "echo $LINE".. i'm betting that $LINE doesn't have a numerical value when the expr command is executed..
# 14  
Old 07-09-2003
echo $LINE gives me proper number when I execute manually, through cron, tyhe logfile says "expr: Syntax error"


Please help !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed script help

I am having a file as stated below : File 1: ########################## idnd a integer 2; list 1 ; list2 ; chip top alist( .a(1) , .b(2) , .c(3) , .d(1) , .e(7) , .n(80), .d(1) , .g(7) , .n(80), .f(1) , .e(7) , .m(80)); lis 7 nfj ; jdjd kn; jsjd l ; (4 Replies)
Discussion started by: kshitij
4 Replies

2. Shell Programming and Scripting

SED script

Hi , i am stuck in this simple script. #!/bin/ksh echo "enter the file name" read flname echo "enter version" read ver grep $flname /home/con/snsc/perl/map > flplist dirname `cat flplist` | sed 's/\/so${vers}\//\/so${vers}_xyz\//' > dirlist the map file is basically a list of file... (3 Replies)
Discussion started by: debu182
3 Replies

3. Shell Programming and Scripting

sed script

I am beginner for Unix. I practicing unix shell script. I worked out some sed script example from internet. Everything fine. But in real unix environment, where sed script is mainly used.? Can anyone give some examples for the usage of sed script in real unix environment. It will be useful for... (1 Reply)
Discussion started by: gwgreen1
1 Replies

4. Homework & Coursework Questions

Sed script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a sed script that will display a list of all users in the /etc/passwd file that belong to the group... (0 Replies)
Discussion started by: lakers34kb
0 Replies

5. Shell Programming and Scripting

sed in script

I'm trying to write a simple script that replaces a string. The script works for uninterrupted strings, but as soon as sed encounters a space it stops reading the new string. I've tried double quotations in sed and backslashes before the $, however these don't work. Below is the script. Any help... (9 Replies)
Discussion started by: dsell002
9 Replies

6. UNIX for Dummies Questions & Answers

sed script

:rolleyes: I have a series of folders /temp/a /temp/b /temp/c In folders a, b, and c, I have files a1.txt..........a20.txt b1.txt..........b40.txt & c1.txt..........c60.txt Each file has the same data format :- Line... (2 Replies)
Discussion started by: grinder182533
2 Replies

7. Shell Programming and Scripting

sed script

how to convert the follow sed script file into a command line ? example: /^\.TS/,/^\.TE/{ /^$/p } I have tried the below but it is not working: # sed -n "/^\.TS/,/^\.TE/{/^$/p}" file file: 111 .TS 222 $333 << extract this line 444 .TE 555 (2 Replies)
Discussion started by: 3Gmobile
2 Replies

8. Shell Programming and Scripting

sed in a script

I am trying to run a sed command within a script to edit a file. I am trying to put the value of MYUSER into the sshd_config file. Instead of putting the value of the variable, MYUSER, it puts in the string ${MYUSER}. Anyone know a good solution to this? cat ${SSHD_CONFIG} | sed... (1 Reply)
Discussion started by: Mike_the_Man
1 Replies

9. Shell Programming and Scripting

Sed script

/\/\*/!b :x /\*\//!{ N bx } s/\/\*.*\*\/// This scipt should remove c like commnets /**/ i know what de last line does but i dont't know what the first lines do Can anyone explain please (3 Replies)
Discussion started by: clauchiorean
3 Replies

10. Shell Programming and Scripting

Sed script maybe?

I have a lot of script files that were created by Extract in a dir that no longer exists. Now that I have to run these scripts they 'all' have to be changed. I'm looking for a way to do a 'mass' change if possible. So far, I've dumped all of the script file names to a file and sorted them to... (5 Replies)
Discussion started by: HOlli
5 Replies
Login or Register to Ask a Question