Sponsored Content
Top Forums Shell Programming and Scripting search a word and delete consecutive lines below it Post 302245342 by vikas027 on Friday 10th of October 2008 01:29:21 AM
Old 10-10-2008
Question search a word and delete consecutive lines below it

Hi all coders,

I need a help to process some data.

I have this file,
Code:
    3 09/21/08 03:32:07 started  undef    mino Oracle           nmx004.wwdc.numonyx.co
m
               Message Text : The Oracle session with the PID 1103 has a CPU time
                              consuming of 999.00 minutes for the instance NCD.


   24 09/13/08 19:18:37 finished undef    mino Oracle           nmx002.wwdc.numonyx.co
m
               Message Text : SID: psoft in install: /oracle/software error:
                              ORA-1652: unable to extend temp segment by 128 in
                              tablespace PSTEMP

   21 09/16/08 02:38:58 finished undef    mino Oracle           nmx005.wwdc.numonyx.co
m
               Message Text : SID: hrqa in install: /oracle/software error:
                              ORA-1652: unable to extend temp segment by 128 in
                              tablespace PSTEMP

      10/08/08 17:34:44 undef    undef    warn OpC              eux1b3.wwdc.numonyx.co
m
               Message Text : Cannot load policy. Reason: (conf-33) Could not
                              validate the signature for policy data file
                              '/var/opt/OV/datafiles/policies/msgi/7e6d68a0-8b3b-71d
                              9-1958-a481e18f0000_data', policy name 'ESM_fs_opcmsg'
                              and policy id '7e6d68a0-8b3b-71d9-1958-a481e18f0000'.
                               (OpC40-1867)
                              Cannot load policy. Reason: (conf-33) Could not
                              validate the signature for policy data file
                              '/var/opt/OV/datafiles/policies/msgi/820f9d70-8b3b-71d
Selected active                                                   Page:      2

Dup.  Date/Time         Auto St. Oper St. Sev. Message Group    Node Name
----- ----------------- -------- -------- ---- ---------------- -------------------

                              9-1958-a481e18f0000_data', policy name
                              'sy-opcmsg(1|3)' and policy id
                              '820f9d70-8b3b-71d9-1958-a481e18f0000'.
                               (OpC40-1867)
                              Ignoring the policies listed above. (OpC40-1899)

What I need is to search a word "Selected" or "Page:" and delete that line as well as next 4 lines. These are the lines which are in bold.

Can we use sed here, actually I come across an example in which we can specify a line and delete next few lines from it.

delete few lines after a specific line
Code:
# delete 6 lines from line 8
  sed -i 8,+6d file.txt

.

I am sure "sed/awk" can help me but not able to use, tried google and many hit and trials, but could not succeed. Smilie

Pls help.

Thanks in adv.

Regards,
VIKAS
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search 2 lines and delete above line

Hi, I've been searching in this forum for the last 4 hours trying to do one thing: search 2 lines and delete the above line. So far I have not be able to find something similar in this forum, so I need help. This is what I'm trying to do. For example, I have a file called file1: file1 word1... (4 Replies)
Discussion started by: shamushamu
4 Replies

2. Shell Programming and Scripting

delete lines containing a specific word in afile

Hi, Please suggest how to write a shell script which delets all the lines containing the word unix in the files supplied as argument in the shell. (4 Replies)
Discussion started by: sireesha9
4 Replies

3. Shell Programming and Scripting

How to delete all lines before a specific word?

Let's say we have a file containing: alllllsadfsdasdf qwdDDDaassss ccxxcxc#2222 dssSSSSddDDDD D1Sqn2NYOHgTI Hello Alex ssS@3 Ok, and let's say we want to delete all words from D1Sqn2NYOHgTI and back, this means to delete the words (and the lines of them) : alllllsadfsdasdf... (2 Replies)
Discussion started by: hakermania
2 Replies

4. Shell Programming and Scripting

how to delete two consecutive lines from the file

Hi guys I am deleting a unique line from the file and also need to remove the line above it which is NOT unique and servers as a record separator. Here is an example: # 101 803E 823F 8240 # 102 755f 4F2A 4F2B # 290 747D 0926 0927 # 999 8123 813E ... (5 Replies)
Discussion started by: aoussenko
5 Replies

5. Shell Programming and Scripting

Search the word to be deleted and delete lines above this word starting from P1 to P3

Hi, I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this: Records P1 10,23423432 ,77:1 ,234:2 P2 10,9089004 ,77:1 ,234:2 ,87:123 ,9898:2 P3 456456 P1 :123,456456546 P2 abc:324234 (2 Replies)
Discussion started by: vsachan
2 Replies

6. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

7. Shell Programming and Scripting

search and delete the lines in a file

HI group members I am new in unix I want to search # symbol in a file. if found need to delete the entire row in the file. need to move the actual data(with out # symbol data) to another file. Thanks (2 Replies)
Discussion started by: pmreddy
2 Replies

8. UNIX for Dummies Questions & Answers

Delete 26 consecutive lines in a file

I have a text file that is about 90,000 lines long. How would I delete lines 64-89, 152-177, 240-265, 328-353... etc? The sections I would like to delete are 26 lines long and the number of lines between the sections I would like to delete is 62 lines. Thanks very much in advance. (6 Replies)
Discussion started by: MDeBiasse
6 Replies

9. UNIX for Dummies Questions & Answers

Delete lines with a word and their above lines

Hi, i have a file like this: A1 kdfjdljfdkljfdlf A2 lfjdlfkjddkjf A3 ***no hit*** A4 ldjfldjfdk A5 ***no hit*** A6 jldfjdlfjdlkfjd I want to remove the lines "***no hit*** and their above line to get an output file like this: (11 Replies)
Discussion started by: the_simpsons
11 Replies

10. Shell Programming and Scripting

Delete all CONSECUTIVE text lines from file shell scripting

Hi I have a text file like below. THe content of the text will vary. Entire text file have four consecutive lines followed with blank line. I want to delete the occurrence of the two consicutive lines in the text file. I don't have pattern to match and delete. Just i need to delete all... (5 Replies)
Discussion started by: RJSKR28
5 Replies
bup-margin(1)						      General Commands Manual						     bup-margin(1)

NAME
bup-margin - figure out your deduplication safety margin SYNOPSIS
bup margin [options...] DESCRIPTION
bup margin iterates through all objects in your bup repository, calculating the largest number of prefix bits shared between any two entries. This number, n, identifies the longest subset of SHA-1 you could use and still encounter a collision between your object ids. For example, one system that was tested had a collection of 11 million objects (70 GB), and bup margin returned 45. That means a 46-bit hash would be sufficient to avoid all collisions among that set of objects; each object in that repository could be uniquely identified by its first 46 bits. The number of bits needed seems to increase by about 1 or 2 for every doubling of the number of objects. Since SHA-1 hashes have 160 bits, that leaves 115 bits of margin. Of course, because SHA-1 hashes are essentially random, it's theoretically possible to use many more bits with far fewer objects. If you're paranoid about the possibility of SHA-1 collisions, you can monitor your repository by running bup margin occasionally to see if you're getting dangerously close to 160 bits. OPTIONS
--predict Guess the offset into each index file where a particular object will appear, and report the maximum deviation of the correct answer from the guess. This is potentially useful for tuning an interpolation search algorithm. --ignore-midx don't use .midx files, use only .idx files. This is only really useful when used with --predict. EXAMPLE
$ bup margin Reading indexes: 100.00% (1612581/1612581), done. 40 40 matching prefix bits 1.94 bits per doubling 120 bits (61.86 doublings) remaining 4.19338e+18 times larger is possible Everyone on earth could have 625878182 data sets like yours, all in one repository, and we would expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. Reading indexes: 100.00% (1612581/1612581), done. 915 of 1612581 (0.057%) SEE ALSO
bup-midx(1), bup-save(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-margin(1)
All times are GMT -4. The time now is 10:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy