I am glad if it was useful, @jiam912
The code has grown a bit, but I could not find another way to get around the buffer size limit
The problem was as follows.
If the string starting with 'a' was even line then the code did not work properly.
Add the 'l' command to look at the contents of the buffer (the line marked at the end with a dollar sign)
and add one line to the input file.
а new version
Last edited by nezabudka; 02-29-2020 at 02:52 AM..
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)
Hi, I've searched in this forum all day long but was not able to find enough codes to help me do a task. The only code that I can come up with is this:
sed '/ /,/ /{//p;d;}' inputfile > outputfile
I would like to sed/awk/grep a file for two patterns and then delete the lines between... (4 Replies)
Hi All,
Below is my requirement. Whatever coming in between ' ', needs to delete.
Input File Contents:
==============
This is nice 'boy'
This 'is
bad
boy.' Got it
Expected Output
===========
This is nice
This
Got it (4 Replies)
Hello sed gurus. I am using ksh on Sun and have a file created by concatenating several other files. All files contain header rows. I just need to keep the first occurrence and remove all other header rows.
header for file
1111
2222
3333
header for file
1111
2222
3333
header for file... (8 Replies)
Hi,
i need help to delete all the lines between 2 matched patterns and the first pattern must be deleted too. sample as follows:
inputfile.txt
>kump_1
...........................
...........................
>start_0124
dgfhghgfh
fgfdgfh
fdgfdh
>kump_2
............................. (7 Replies)
'Hi
I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match.
Which option is to be used to exclude the line containing the pattern?
sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
I have a file
Line 1 a
Line 22
Line 33
Line 1 b
Line 22
Line 1 c
Line 4
Line 5
I want to delete all lines before last occurrence of a line which contains something which is defined in a variable. Say a variable var contains 'Line 1', then I need the following in the output.
... (21 Replies)
Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" .
I have attached sample input file and the desired input should be as:
INPUT FORMAT:
SELECT
ABCD,
DEFGH,
DFGHJ,
JKLMN,
AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
LEARN ABOUT BSD
bm
BM(PUBLIC) BM(PUBLIC)
NAME
bm - search a file for a string
SYNOPSIS
/usr/public/bm [ option ] ... [ strings ] [ file ]
DESCRIPTION
Bm searches the input files (standard input default) for lines matching a string. Normally, each line found is copied to the standard out-
put. It is blindingly fast. Bm strings are fixed sequences of characters: there are no wildcards, repetitions, or other features of regu-
lar expressions. Bm is also case sensitive. The following options are recognized.
-x (Exact) only lines matched in their entirety are printed
-l The names of files with matching lines are listed (once) separated by newlines.
-c Only a count of the number of matches is printed
-e string
The string is the next argument after the -e flag. This allows strings beginning with '-'.
-h No filenames are printed, even if multiple files are searched.
-n Each line is preceded by the number of characters from the beginning of the file to the match.
-s Silent mode. Nothing is printed (except error messages). This is useful for checking the error status.
-f file
The string list is taken from the file.
Unless the -h option is specified the file name is shown if there is more than one input file. Care should be taken when using the charac-
ters $ * [ ^ | ( ) and in the strings (listed on the command line) as they are also meaningful to the Shell. It is safest to enclose the
entire expression argument in single quotes ' '.
Bm searches for lines that contain one of the (newline-separated) strings, using the Boyer-Moore algorithm. It is far superior in terms of
speed to the grep (egrep, fgrep) family of pattern matchers for fixed-pattern searching, and its speed increases with pattern length.
SEE ALSO grep(1)DIAGNOSTICS
Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files.
AUTHOR
Peter Bain (pdbain@wateng), with modifications suggested by John Gilmore
BUGS
Only 100 patterns are allowed.
Patterns may not contain newlines.
If a line (delimited by newlines, and the beginning and end of the file) is longer than 8000 charcters (e.g. in a core dump), it will not
be completely printed.
If multiple patterns are specified, the order of the ouput lines is not necessarily the same as the order of the input lines.
A line will be printed once for each different string on that line.
The algorithm cannot count lines.
The -n and -c work differently from fgrep.
The -v, -i, and -b are not available.
4th Berkeley Distribution 8 July 1985 BM(PUBLIC)