Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Find Pattern delete line and next line Post 302338513 by rdhanek on Tuesday 28th of July 2009 06:17:34 AM
Old 07-28-2009
Find Pattern delete line and next line

I am trying to delete the line with pattern and the next line. Found the below command in forum which also deleted the previous line. how should i modify that to make sure that only the line with pattern and the next line are deleted but not the previous line?

Code:
awk '/key word/{x="";getline;next}{if(x)print x;x=$0}END{if(x)print x}' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies

2. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

3. Shell Programming and Scripting

sed find matching pattern delete next line

trying to use sed in finding a matching pattern in a file then deleting the next line only .. pattern --> <ad-content> I tried this but it results are not what I wish sed '/<ad-content>/{N;d;}' akv.xml > akv5.xml ex, <Celebrant2First>Mickey</Celebrant2First> <ad-content> Minnie... (2 Replies)
Discussion started by: aveitas
2 Replies

4. UNIX for Dummies Questions & Answers

find pattern delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: W/D FRM CHK 00 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (1 Reply)
Discussion started by: nickg
1 Replies

5. Shell Programming and Scripting

find pattern, delete line with pattern and line above and line below

I have a file that will sometimes contain a pattern. The pattern is this: FRM CHK 0000 I want to find any lines with this pattern, delete those lines, and also delete the line above and the line below. (4 Replies)
Discussion started by: nickg
4 Replies

6. Shell Programming and Scripting

sed to find pattern and delete line before and after

I have the following file: line1 line2 MATCH line3 line4 I need to find the pattern, "MATCH" and delete the line before and after MATCH. So the result should be line1 MATCH lline4 I have to use sed because it is the only utility that is common across my environments. I... (1 Reply)
Discussion started by: craftereric
1 Replies

7. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

8. Shell Programming and Scripting

Multiple pattern find and delete line

I have a file # cat /tmp/user_find.txt /home/user/bad_link1 /home/user/www /home/user/mail /home/user/access_logs /home/user/bad_link2 I need to delete lines where there are patterns /home/user/www, /home/user/mail and /home/user/access_logs. I used below method, but its throwing error... (8 Replies)
Discussion started by: anil510
8 Replies

9. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
GRID-MAPFILE-DELET(8)						  Globus Commands					     GRID-MAPFILE-DELET(8)

NAME
grid-mapfile-delete-entry - Remove entries from a gridmap file SYNOPSIS
grid-mapfile-delete-entry [-help] [-usage] [-version] [-versions] grid-mapfile-delete-entry {-dn DISTINGUISHED-NAME} {-ln LOCAL-NAME...} [[-d] | [-dryrun]] [[-mapfile MAPFILE] | [-f MAPFILE]] DESCRIPTION
The grid-mapfile-delete-entry program deletes mappings from a gridmap file. If both the -dn and -ln> options are specified, grid-mapfile-delete-entry removes entries which meet both criteria (remove entries mapping DISTINGUISHED-NAME to LOCAL-NAME for each LOCAL-NAME specified). If only -dn or -ln is specified all entries for that DISTINGUISHED-NAME or LOCAL-NAME are removed. By default, grid-mapfile-delete-entry will modify the gridmap file named by the GRIDMAP environment variable if present, or the file /etc/grid-security/grid-mapfile if not. This can be changed by the use of the -mapfile or -f command-line options. Prior to modifying a gridmap file, grid-mapfile-delete-entry saves its current contents to a file with the string .old appended to the original file name. The full set of command-line options to grid-mapfile-delete-entry are: -help, -usage Display the command-line options to grid-mapfile-delete-entry. -version, -versions Display the version number of the grid-mapfile-delete-entry command. The second form includes more details. -dn DISTINGUISHED-NAME The X.509 distinguished name to remove from the gridmap file. If the -ln option is not specified, remove all entries for this name; otherwise, remove entries that match both this name and the local name. The name should be in OpenSSL's oneline format. -ln LOCAL-NAME... The POSIX user name to remove from the gridmap file. Include multiple LOCAL-NAME strings after the -ln command-line option to remove multiple names from the gridmap. If the -dn option is not specifeid, remove all entries for these names; otherwise, remove entries that match the DISTINGUISHED-NAME and any of the LOCAL-NAME values. -d, -dryrun Display diagnostics about what would be removed from the gridmap file, but don't actually modify the file. -mapfile MAPFILE, -f MAPFILE Modify the gridmap file named by MAPFILE instead of the default. EXAMPLES
Remove all mappings for a distinguished name: % grid-mapfile-delete-entry "/DC=org/DC=example/DC=grid/CN=Joe User" Modifying /etc/grid-security/grid-mapfile ... Deleting entry: "/DC=org/DC=example/DC=grid/CN=Joe User" juser,juser2 (1) entry deleted Remove the mapping between a distinguished name and a single local username: % grid-mapfile-delete-entry "/DC=org/DC=example/DC=grid/CN=Joe User" -ln juser2 Modifying /etc/grid-security/grid-mapfile ... Current entry: "/DC=org/DC=example/DC=grid/CN=Joe User" juser (1) mapping removed: (juser2), (0) not present and ignored (0) entries deleted ENVIRONMENT VARIABLES
The following environment variables affect the execution of grid-mapfile-delete-entry: GRIDMAP Path to the default gridmap to modify. FILES
The following files affect the execution of grid-mapfile-delete-entry: /etc/grid-security/grid-mapfile Path to the default gridmap to modify if GRIDMAP environment variable is not set. SEE ALSO
grid-mapfile-add-entry(8), grid-mapfile-check-consistency(8) AUTHOR
University of Chicago Globus Toolkit 5.0.1 03/19/2010 GRID-MAPFILE-DELET(8)
All times are GMT -4. The time now is 06:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy