Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Delete multiple lines between blank lines containing two patterns Post 303018933 by ce9888 on Tuesday 19th of June 2018 10:43:03 AM
Old 06-19-2018
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:

Code:
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
parameter_2 = 0
parameter_3 = 1

user: beta
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0

.

I want to delete the paragraph containing the same user and the same parameter_1, in the exemple: user=alpha and parameter_1=15 . The expected result should be:
Code:
user: alpha
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0

user: alpha
parameter_1 = 16
parameter_2 = 0
parameter_3 = 1

user: beta
parameter_1 = 15
parameter_2 = 1
parameter_3 = 0

.

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete blank lines or lines with spaces only

hi there i'm trying to delete blank lines and or lines with spaces only from a series of files in an directory. to do so, i'm using this: for files in `ls /users/myname/pesop* 2>/dev/null` do grep -v ^$ $files > newfile mv newfile $files done now, this works great for blank lines but... (3 Replies)
Discussion started by: vascobrito
3 Replies

2. Shell Programming and Scripting

regex to delete multiple blank lines in a file?

can't figure out a way to delete multiple empty lines but keep single empty lines in a file, file is like this #cat file 1 2 3 4 5 6 - What I want is 1 2 (6 Replies)
Discussion started by: fedora
6 Replies

3. UNIX for Dummies Questions & Answers

delete blank lines from a file

can anyone show me how to delete blank lines from a file. thanks in advance (2 Replies)
Discussion started by: sachin.gangadha
2 Replies

4. UNIX for Dummies Questions & Answers

delete traling blank lines only

Hi, I have blank line in the file, I just want to remove trailing blank lines. There are some blank lines between the lines, i don't want remove those. Just want to delete blank lines at the end. I used this command sed '/^$/d' infile > outfile, but it is not removing anything. I think... (1 Reply)
Discussion started by: visu
1 Replies

5. Shell Programming and Scripting

Why cant i delete blank lines?

I have a sed pipeline: myVar=$(cat $FILE | sed -n '/regex/,/regex/{/regex/d;p}' | sed -n '/regex/!p' | sed -e s/*:// | sed /regex/,+8d \ ) sed '/^$/d' sed '/./!d' And i've tried to add that in a different order rather then just on the end..Why isnt it deleting all the blank... (2 Replies)
Discussion started by: omgsomuchppl
2 Replies

6. Shell Programming and Scripting

delete lines between patterns

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)
Discussion started by: shamushamu
4 Replies

7. Shell Programming and Scripting

Delete blank lines, if blank lines are more than one using shell

Hi, Consider a file named "testfile" The contents of file are as below first line added for test second line added for test third line added for test fourth line added for test fifth line added for test (5 Replies)
Discussion started by: anil8103
5 Replies

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

9. Shell Programming and Scripting

Delete blank lines in a file

Hi All, I have a file and I need to delete the lines that are blank and is starting with some characters below. Something like below: Regular Ascii File: Line1: AGODA1 BUSAN||SK Lord Beach 4/6/2012 4/7/2012 68060 Line2: AGODA2 BUSAN||SK Beach Hotel 4/6/2012 4/7/2012 610200 Line3: ... (4 Replies)
Discussion started by: rkumar28
4 Replies

10. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies
DLAGTM(l)								 )								 DLAGTM(l)

NAME
DLAGTM - perform a matrix-vector product of the form B := alpha * A * X + beta * B where A is a tridiagonal matrix of order N, B and X are N by NRHS matrices, and alpha and beta are real scalars, each of which may be 0., 1., or -1 SYNOPSIS
SUBROUTINE DLAGTM( TRANS, N, NRHS, ALPHA, DL, D, DU, X, LDX, BETA, B, LDB ) CHARACTER TRANS INTEGER LDB, LDX, N, NRHS DOUBLE PRECISION ALPHA, BETA DOUBLE PRECISION B( LDB, * ), D( * ), DL( * ), DU( * ), X( LDX, * ) PURPOSE
DLAGTM performs a matrix-vector product of the form B := alpha * A * X + beta * B where A is a tridiagonal matrix of order N, B and X are N by NRHS matrices, and alpha and beta are real scalars, each of which may be 0., 1., or -1. ARGUMENTS
TRANS (input) CHARACTER Specifies the operation applied to A. = 'N': No transpose, B := alpha * A * X + beta * B = 'T': Transpose, B := alpha * A'* X + beta * B = 'C': Conjugate transpose = Transpose N (input) INTEGER The order of the matrix A. N >= 0. NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrices X and B. ALPHA (input) DOUBLE PRECISION The scalar alpha. ALPHA must be 0., 1., or -1.; otherwise, it is assumed to be 0. DL (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) sub-diagonal elements of T. D (input) DOUBLE PRECISION array, dimension (N) The diagonal elements of T. DU (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) super-diagonal elements of T. X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) The N by NRHS matrix X. LDX (input) INTEGER The leading dimension of the array X. LDX >= max(N,1). BETA (input) DOUBLE PRECISION The scalar beta. BETA must be 0., 1., or -1.; otherwise, it is assumed to be 1. B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) On entry, the N by NRHS matrix B. On exit, B is overwritten by the matrix expression B := alpha * A * X + beta * B. LDB (input) INTEGER The leading dimension of the array B. LDB >= max(N,1). LAPACK version 3.0 15 June 2000 DLAGTM(l)
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy