Sponsored Content
Full Discussion: help in sed script
Top Forums UNIX for Dummies Questions & Answers help in sed script Post 38079 by abhi123 on Monday 7th of July 2003 01:21:54 AM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
PERFMON(4)                                               BSD/i386 Kernel Interfaces Manual                                              PERFMON(4)

NAME
perfmon -- CPU performance-monitoring interface SYNOPSIS
cpu I586_CPU cpu I686_CPU options PERFMON DESCRIPTION
The perfmon driver provides access to the internal performance-monitoring capabilities of the Intel Pentium and Pentium Pro CPUs. These pro- cessors implement two internal counters which can be configured to measure a variety of events for either count or duration (in CPU cycles), as well as a cycle counter which counts clock cycles. The perfmon driver provides a device-style interface to these capabilities. All access to the performance-monitoring counters is performed through the special device file ``/dev/perfmon''. This device supports a num- ber of ioctl(2) requests, defined in <machine/perfmon.h> along with the definitions of the various counters for both Pentium and Pentium Pro processors. NOTA BENE: The set of available events differs from processor to processor. It is the responsibility of the programmer to ensure that the event numbers used are the correct ones for the CPU type being measured. The following ioctl(2) requests are defined: PMIOSETUP (struct pmc) Set up a counter with parameters and flags defined in the structure. The following fields are defined in struct pmc: int pmc_num the number of the counter in question; must be less than NPMC (currently 2). u_char pmc_event the particular event number to be monitored, as defined in <machine/perfmon.h>. u_char pmc_unit the unit mask value, specific to the event type (see the Intel documentation). u_char pmc_flags flags modifying the operation of the counter (see below). u_char pmc_mask the counter mask value; essentially, this is a threshold used to restrict the count to events lasting more (or less) than the specified number of clocks. The following pmc_flags values are defined: PMCF_USR count events in user mode PMCF_OS count events in kernel mode PMCF_E count number of events rather than their duration PMCF_INV invert the sense of the counter mask comparison PMIOGET (struct pmc) returns the current configuration of the specified counter. PMIOSTART PMIOSTOP (int) starts (stops) the specified counter. Due to hardware deficiencies, counters must be started and stopped in numerical order. (That is to say, counter 0 can never be stopped without first stopping counter 1.) The driver will not enforce this restriction (since it may not be present in future CPUs). PMIORESET (int) reset the specified counter to zero. The counter should be stopped with PMIOSTOP before it is reset. All counters are automatically reset by PMIOSETUP. PMIOREAD (struct pmc_data) get the current value of the counter. The pmc_data structure defines two fields: int pmcd_num the number of the counter to read quad_t pmcd_value the resulting value as a 64-bit signed integer In the future, it may be possible to use the RDPMC instruction on Pentium Pro processors to read the counters directly. PMIOTSTAMP (struct pmc_tstamp) read the time stamp counter. The pmc_tstamp structure defines two fields: int pmct_rate the approximate rate of the counter, in MHz quad_t pmct_value the current value of the counter as a 64-bit integer It is important to note that the counter rate, as provided in the pmct_rate field, is often incorrect because of calibration dif- ficulties and non-integral clock rates. This field should be considered more of a hint or sanity-check than an actual represen- tation of the rate of clock ticks. FILES
/dev/perfmon character device interface to counters /usr/include/machine/perfmon.h include file with definitions of structures and event types /usr/share/examples/perfmon sample source code demonstrating use of all the ioctl() commands SEE ALSO
ioctl(2), hwpmc(4) Intel Corporation, Pentium Pro Family Developer's Manual, vol. 3, January 1996, Operating System Writer's Manual. HISTORY
The perfmon device first appeared in FreeBSD 2.2. AUTHORS
The perfmon driver was written by Garrett A. Wollman, MIT Laboratory for Computer Science. BSD March 26, 1996 BSD
All times are GMT -4. The time now is 08:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy