Delete lines and the first pattern between 2 matched patterns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete lines and the first pattern between 2 matched patterns
# 8  
Old 08-02-2013
Yes that's the safer strategy. As one-liner:
Code:
sed -n -e '/^>kump/{:top' -e 'n; /^>/!b top' -e '}' -e p file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Delete multiple lines between blank lines containing two patterns

Hi all, I'm looking for a way (sed or awk) to delete multiple lines between blank lines containing two patterns ex: user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 15 parameter_2 = 1 parameter_3 = 0 user: alpha parameter_1 = 16... (3 Replies)
Discussion started by: ce9888
3 Replies

2. Shell Programming and Scripting

awk to delete content before and after a matched pattern

Hello, I have been trying to write a script where I could get awk to delete data before and after a matched pattern. For eg Raw data Start NAME = John Age = 35 Occupation = Programmer City = New York Certification Completed = No Salary = 80000 End Start NAME = Mary Age = 25... (2 Replies)
Discussion started by: sidnow
2 Replies

3. Shell Programming and Scripting

Print line between two patterns when a certain pattern matched

Hello Friends, I need to print lines in between two string when a keyword existed in those lines (keywords like exception, error, failed, not started etc). for example, input: .. Begin Edr ab12 ac13 ad14 bc23 exception occured bd24 cd34 dd44 ee55 ff66 End Edr (2 Replies)
Discussion started by: EAGL€
2 Replies

4. Shell Programming and Scripting

Grep command to return all the lines between one matched pattern to another.

14:15:00- abcdefghijkl. 14:30:00- abcdefghijkl. 14:35:00- abcdefghijkl. 123456789. 123456789. 14:45:00- abcdefghijkl. 14:50:00- abcdefghijkl. 123456789. 15:30:00-abcdefghijkl. (3 Replies)
Discussion started by: dev_shivv
3 Replies

5. Solaris

Grep command to return all the lines from one matched pattern to another.

For example a log file looks like below- 13:30:00- abcdefghijklhjghjghjhskj. abcdefghijkl. 14:15:00- abcdefghijkl. 14:30:00- abcdefghijkl. 14:35:00- abcdefghijkl. 123456789. 123456789. 14:45:00- abcdefghijkl. (0 Replies)
Discussion started by: dev_shivv
0 Replies

6. Shell Programming and Scripting

removing lines around a matched pattern

I have an ugly conf file that has the string I'm interested in searching for in the middle of a block of code that's relevant, and I'm trying to find a way to remove that entire block based on the matched line. I've googled for this problem, and most people helping are only interested in... (9 Replies)
Discussion started by: tamale
9 Replies

7. Shell Programming and Scripting

delete two patterns and remove one pattern

Friends, I have .txt file with following format. START ABC|Prashant1|Patel1 ABC|Prashant2|Patel2 ABC|Prashant1|Patel1 ABC|Prashant2|Patel2 END I would like to do: 1) Delete line with START 2) Delete line with END 3) Remove ABC| 4) Delete duplicate records The following command... (7 Replies)
Discussion started by: ppat7046
7 Replies

8. Shell Programming and Scripting

Delete lines between two patterns without deleting the second pattern

I want to delete lines like this sed '/FROM_HERE/,/TO_HERE/d' but I would like to *not* delete the second match, i.e. the TO_HERE line. How can I achieve this? Thank you! (1 Reply)
Discussion started by: Ilja
1 Replies

9. Shell Programming and Scripting

SED: delete and print the only exact matched pattern

I am really need help with the regular expression in SED. From input file, I need to extract lines that have the port number (sport or dport) as defined. The input file is something like this time=1209515280-1209515340 dst=192.168.133.202 src=208.70.8.23 bytes=2472 proto=6 sport=80 dport=1447... (6 Replies)
Discussion started by: new_buddy
6 Replies

10. Shell Programming and Scripting

SED: match pattern & delete matched lines

Hi all, I have the following data in a file x.csv: > ,this is some text here > ,,,,,,,,,,,,,,,,2006/11/16,0.23 > ,,,,,,,,,,,,,,,,2006/12/16,0.88 < ,,,,,,,,,,,,,,,,this shouldnt be deleted I need to use SED to match anything with a > in the line and delete that line, can someone help... (7 Replies)
Discussion started by: not4google
7 Replies
Login or Register to Ask a Question
CHDB(7) 						 Miscellaneous Information Manual						   CHDB(7)

NAME
chdb - chess database browser SYNOPSIS
chdb [ file ... ] DESCRIPTION
Chdb reads the given files of chess games (hist by default) and accepts commands to search, play through, and display the games in these files. If x is the name of the file, it is looked for under the names x, x.m.out, and /lib/chess/x.m.out. After reading the files, chdb displays a chess board, a text window with a command line, and vertical and horizontal scroll bars along the edges of the board. The text window holds 6 lines of information about the game and position and, at the bottom, a command line in which to type. The displayed text contains chess symbols--use a suitable font. The vertical scroll bar scans through the games to select a game; the horizontal bar then scans through the moves of the selected game. Both scroll bars use button 1 to scan backwards, button 3 to scan forwards, and button 2 to jump to an absolute position. With buttons 1 and 3, the scroll bars are calibrated in units of 1 through 8 corresponding to the ranks and files of the board. The units measure games on the vertical scroll bar, ply (half-moves) on the horizontal scroll bar. For example, clicking button 3 on the horizontal scroll bar under the d file steps through the game two full moves. Moves may be made on the chess board by pointing with button 1. There are two methods to point at moves. For the first method, point at the piece to be moved, press button 1, point to the place to move that piece, and release button 1. In the second method, point at the place where a piece is to move and press button 1. The smallest/least-central piece that can move there is highlighted. Releasing button 1 without moving the mouse will make the highlighted move. Moving the mouse to the desired piece and releasing the button will move the selected piece. Typed lines of text are echoed in the command line and executed. The available commands are: f n n Set the format for display of moves in the text window. The first number is the verbosity, with 0 minimal. The second number is 0 for algebraic, 1 for English, and 2 for figurine (default). g n Go to the game with ordinal number n in the input files. If n is prefixed with a + or -, it is interpreted as a relative position in the current set of games (see below). N defaults to +1. p n Go to whole move n in the current game. If n is prefixed with a + or -, it is interpreted as an offset in ply from the current position. N defaults to +1. k n Mark the current set of games with tag n (see patterns, below). w type file Write the current set of games to file. Type is either a (write the games as text) or m (write the games in binary format suitable for chdb). Patterns select subsets of the games. A pattern is one of the following, in decreasing precedence order. Parentheses can be used for grouping. . The current game. * All games originally read. 'n The games previously marked with a k command with the same n. [] [number] All games in * that contain the positions that can be reached in the specified number of plies from the current position. A missing number is the same as zero, meaning just the current position. Positions are matched with black/white transpositions. /regular expression/fields This pattern matches the regular expression against the various text windows. Fields is a list of characters from the set abdefo- prw. A is for all, b for black, d for date, e for event, f for file, o for opening, p for person (white and black), r for result, and w for white. If multiple fields are given, the expression is matched on the union of the specified fields. If no field is given, p is assumed. !pattern The set subtraction of * and the given pattern. pattern-pattern The set subtraction of the given patterns. pattern+pattern pattern|pattern The set union of the given patterns. pattern pattern pattern&pattern The set intersection of the given patterns. +pattern -pattern &pattern |pattern These patterns have the current set of games as an implied first operand. EXAMPLE
Select games that Botvinnik lost: (/Botv/w/0-1/r)|(/Botv/b/1-0/r) FILES
/lib/chess directory of databases. SOURCE
/sys/src/cmd/chdb SEE ALSO
regexp(6). BUGS
The browser is only a prototype. Most of the databases are protected by copyright and not distributed. CHDB(7)