find 2 line numbers, grab text in between


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find 2 line numbers, grab text in between
# 8  
Old 09-26-2006
I just tested this. very nice!
there is only one extra line that I don't need, but it is not a big deal.

PHP Code:
sed -"/Tablespace Percent Total Free/,/Tablespace Free Space Avg Fragmentation/ p" /export/home/oracle/dba/spcchk.lis sed "$ d"
09/25/06      SPCCHK Tablespace Percent Total Free Values on BAT
                                                                   
%chg Days
Tablespace                                                  Today since till
   Name           09
/18 09/19 09/20 09/21 09/22 09/23 09/24 09/25  yest zero
----------------- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
FILE_NDX           25.6  25.5  25.5  25.5  25.4  25.4  25.3  25.3    .0
SYSAUX             40.3  43.0  42.2  41.2  40.3  42.8  42.1  41.2   
-.9
SYSTEM             61.4  61.2  61.2  61.2  61.1  61.1  61.1  61.1    .0
UNDOTBS1           81.4  81.0  81.2  80.8  81.0  80.8  81.0  81.2    .2
USERS              87.1  87.1  87.1  87.1  86.6  86.6  86.6  86.6    .0

## don't need "Fragmentation" line below -- I could just grep -v it out however
09/25/06  SPCCHK Tablespace Free Space Avg Fragmentation Pct on BAT
09
/25/06     SPCCHK Tablespace Percent Total Free Values on CCST
                                                                   
%chg Days
Tablespace                                                  Today since till
   Name           09
/18 09/19 09/20 09/21 09/22 09/23 09/24 09/25  yest zero
----------------- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
ACTIVE_SEATS       14.1  14.1  14.1  12.5  12.5  12.5  12.5  12.5    .0   42
ACTIVE_SEATS_NDX   43.7  43.7  43.7  43.7  43.7  42.2  42.2  42.2    .0  158
ATTEMPTS           25.0  24.2  24.2  24.2  24.2  24.2  24.2  24.2    .0  361
ATTEMPTS_NDX       86.0  86.0  86.0  86.0  86.0  85.9  85.9  85.9    .0
GEN_NDX            48.8  48.8  48.8  48.8  48.8  48.8  48.8  48.6   
-.2
SYSAUX             44.0  46.7  45.8  45.1  44.1  46.7  45.8  45.1   
-.7
SYSTEM             44.2  44.2  44.2  44.2  44.2  44.0  44.0  44.0    .0
UNDOTBS            85.1  84.8  84.9  84.6  84.2  84.1  84.5  85.2    .7 
# 9  
Old 09-26-2006
use this . u wont get unwanted line
Code:
sed -n "/Tablespace Percent Total Free/,/Tablespace Free Space Avg Fragmentation/{ /Tablespace Free Space Avg Fragmentation/!p; }" file

# 10  
Old 09-26-2006
that second script is not working. For some reason it is converting the "!" to something weird.
PHP Code:
graham_ccstsed -"/Tablespace Percent Total Free/,/Tablespace Free Space Avg Fragmentation/ \
> { /Tablespace Free Space Avg Fragmentation/!p; }" 
/export/home/oracle/dba/spcchk.lis
{ /Tablespace Free Space Avg Fragmentation/p[wd; }" /export/home/oracle/dba/spcchk.lis
sed: command garbled: /Tablespace Percent Total Free/,/Tablespace Free Space Avg Fragmentation/ { /Tablespace Free Space Avg Fragmentation/p[wd; } 
# 11  
Old 09-26-2006
try this
Code:
sed -n -f sed_spt file

sed_spt
#############################
/Tablespace Percent Total Free/,/Tablespace Free Space Avg Fragmentation/{ 
/Tablespace Free Space Avg Fragmentation/!p; 
}
#############################

# 12  
Old 09-26-2006
nice! You DA MAN. This is perfect.
Thanks very much.

PHP Code:
sed --f sed_spt /export/home/oracle/dba/spcchk.lis
09
/25/06      SPCCHK Tablespace Percent Total Free Values on BAT
                                                                   
%chg Days
Tablespace                                                  Today since till
   Name           09
/18 09/19 09/20 09/21 09/22 09/23 09/24 09/25  yest zero
----------------- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
FILE_NDX           25.6  25.5  25.5  25.5  25.4  25.4  25.3  25.3    .0
SYSAUX             40.3  43.0  42.2  41.2  40.3  42.8  42.1  41.2   
-.9
SYSTEM             61.4  61.2  61.2  61.2  61.1  61.1  61.1  61.1    .0
UNDOTBS1           81.4  81.0  81.2  80.8  81.0  80.8  81.0  81.2    .2
USERS              87.1  87.1  87.1  87.1  86.6  86.6  86.6  86.6    .0

09
/25/06     SPCCHK Tablespace Percent Total Free Values on CCST
                                                                   
%chg Days
Tablespace                                                  Today since till
   Name           09
/18 09/19 09/20 09/21 09/22 09/23 09/24 09/25  yest zero
----------------- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----
ACTIVE_SEATS       14.1  14.1  14.1  12.5  12.5  12.5  12.5  12.5    .0   42
ACTIVE_SEATS_NDX   43.7  43.7  43.7  43.7  43.7  42.2  42.2  42.2    .0  158
ATTEMPTS           25.0  24.2  24.2  24.2  24.2  24.2  24.2  24.2    .0  361
ATTEMPTS_NDX       86.0  86.0  86.0  86.0  86.0  85.9  85.9  85.9    .0
GEN_NDX            48.8  48.8  48.8  48.8  48.8  48.8  48.8  48.6   
-.2
SYSAUX             44.0  46.7  45.8  45.1  44.1  46.7  45.8  45.1   
-.7
SYSTEM             44.2  44.2  44.2  44.2  44.2  44.0  44.0  44.0    .0
UNDOTBS            85.1  84.8  84.9  84.6  84.2  84.1  84.5  85.2    .7 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find duplicates in file with line numbers

Hello All, This is a noob question. I tried searching for the answer but the answer found did not help me . I have a file that can have duplicates. 100 200 300 400 100 150 the number 100 is duplicated twice. I want to find the duplicate along with the line number. expected... (4 Replies)
Discussion started by: vatigers
4 Replies

2. Shell Programming and Scripting

Grab text after pattern on the same line

data: 8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5i PACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+ 8nwR15UzfeZafaf2bGr8akx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjp lVpOoMLXJ ... (19 Replies)
Discussion started by: SkySmart
19 Replies

3. Shell Programming and Scripting

How to add line numbers (multiples of 5: 0,5,10,15,20) to a text file?

Hi, I need to number the lines in my text file. I know how to do this with standard numbering (1,2,3,4, etc) but I need to count in multiples of 5, beginning 0,5,10,15... example existing file: abcd efg hijklm nopqrs desired output 0 abcd 5 efg 10 hijklm 15 ... (11 Replies)
Discussion started by: livbaddeley
11 Replies

4. Shell Programming and Scripting

How Select numbers from a line of text, and remove leading spaces?

I have a text file with a line of text that contains numbers and text formatted into groups. I need to extract the number that can be either 1,2 or 3 digits long. Then write it to a variable, but i need to remove any leading spaces in the number first. I can get the numbers out but how to remove... (12 Replies)
Discussion started by: kcpoole
12 Replies

5. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

6. Shell Programming and Scripting

How to find numbers in text file?

Hi I have a text file with rows like this: 7 Herman ASI-40 Jungle (L) Blueprint (L) Weapon Herman ASI-40 Jungle (L) 215.00 57 65.21 114.41 and 9 Herman CAP-505 (L) Blueprint (L) Weapon Herman CAP-505 (L) 220.00 46.84 49.1 104.82 and 2 ClericDagger 1C blueprint Melee - Shortblade... (2 Replies)
Discussion started by: pesa
2 Replies

7. Shell Programming and Scripting

How to find the matched numbers between 2 text file using perl program??

hi dudes, I nee you kind assistance, I have to find the matched numbers from 2 text files and output of matched numbers should be in another text file.. I do have text files like this , for example File 1 787 665*5-p 5454 545-p 445-p 5454*-p File 2 5455 787 445-p 4356 2445 144 ... (3 Replies)
Discussion started by: sureshraj
3 Replies

8. Shell Programming and Scripting

Grepping text by providing line numbers.

Dear Friends, I have a flat file from which I want to grep line no. 7,10, 19 to 35, 37. How can it be done? Thank you in advance Anushree (6 Replies)
Discussion started by: anushree.a
6 Replies

9. Shell Programming and Scripting

how to add line numbers in text file

Hi all How to add line numbers in text file.. ex abcd cdef result 1. abcd 2. cdef thx in advance (4 Replies)
Discussion started by: suryanarayana
4 Replies

10. Shell Programming and Scripting

how to print out line numbers of a text file?

i have this text file name test.txt which contain : aaaaa bbb iiiiiiiiiiiii ccf ddaaa ddd and i need a script that can print out the line numbers using a while loop.. so when the script is run..it will have this: 1 2 3 any ideas? :) thanks guys (4 Replies)
Discussion started by: forevercalz
4 Replies
Login or Register to Ask a Question