Sponsored Content
Top Forums Shell Programming and Scripting Delete lines based on pattern match Post 302921320 by kraljic on Thursday 16th of October 2014 10:53:55 AM
Old 10-16-2014
Thank You very much Akshay , Rudic.

Akshay, I forgot to mention that I want to view all the text other than those lines I wanted to skip/delete. I didn't include the lines in red below in my earlier example. I want to see these lines starting with AnotherImportant ... too. ie. All the remaining lines in the file. RudiC's solution caters to this requirement too.


Code:
$ cat someLogfile.txt
AnotherImportan text
Another important test2
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'CMPA' does not exist
Failing sql is:
GRANT SELECT ON "CMPA_USER"."CMPA_CLIENT_VISIT_TX_1909" TO "CMPA"
Some Important text1
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TESTER' does not exist
Failing sql is:
GRANT UPDATE ON "CMPA_USER"."CMPA_CLIENT_VISIT_TX_1909" TO "TESTER"
Some Important text2
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TESTER' does not exist
Failing sql is:
GRANT SELECT ON "CMPA_USER"."CMPA_CLIENT_VISIT_TX_1909" TO "TESTER"
Some Important text3
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TESTER' does not exist
Failing sql is:
GRANT INSERT ON "CMPA_USER"."CMPA_CLIENT_VISIT_TX_1909" TO "TESTER"
Some Important text4
ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-01917: user or role 'TESTER' does not exist
Failing sql is:
GRANT DELETE ON "CMPA_USER"."CMPA_CLIENT_VISIT_TX_1909" TO "TESTER"
Some Important text5
$
$
$
$ ### Akshay's solution ####
$ nawk '/ORA-39083:/{s=FNR+4}FNR==s' someLogfile.txt
Some Important text1
Some Important text2
Some Important text3
Some Important text4
Some Important text5
$
$

$ ### Rudic's solution ### This shows all the remaining lines too
$ awk '/ORA-39083:/{L=NR+4}NR>=L' someLogfile.txt
AnotherImportan text
Another important test2
Some Important text1
Some Important text2
Some Important text3
Some Important text4
Some Important text5

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to delete lines do NOT match a pattern

On Unix, it is easy to get those lines that match a pattern, by grep pattern file or those lines that do not, by grep -v pattern file but I am editing a file on Windows with Ultraedit. Ultraedit support regular expression based search and replace. I can delete all the lines that match a... (1 Reply)
Discussion started by: JumboGeng
1 Replies

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

3. Shell Programming and Scripting

delete a line that does not match the pattern

hi, i am parsing a file, in that searching for lines those contains "$threadNo.Received message:" , if that line contains the required fields write them into a separate file other wise ignore them. i am using the following code,but it is printing all the lines , i dont want to rpint , please help... (3 Replies)
Discussion started by: Satyak
3 Replies

4. Shell Programming and Scripting

sed problem - delete all lines until a match on 2 lines

First of all, I know this can be more eassily done with perl or other scripting languages but, that's not the issue. I need this in sed. (or wander if it's possible ) I got a file (trace file to recreate the control file from oracle for the dba boys) which contains some lines another line... (11 Replies)
Discussion started by: plelie2
11 Replies

5. Shell Programming and Scripting

delete block of lines when pattern does not match

I have this input file that I need to remove lines which represents more than 30 days of processing. Input file: On 11/17/2009 at 12:30:00, Program started processing...argc=7 Total number of bytes in file being processed is 390 Message buffer of length=390 was allocated successfully... (1 Reply)
Discussion started by: udelalv
1 Replies

6. Shell Programming and Scripting

sed/awk : how to delete lines based on IP pattern ?

Hi, I would like to delete lines in /etc/hosts on few workstations, basically I want to delete all the lines for a list of machines like this : for HOST in $(cat stations.lst |uniq) do # echo -n "$HOST" if ping -c 1 $HOST > /dev/null 2>&1 then HOSTNAME_val=`rsh $HOST "sed... (3 Replies)
Discussion started by: albator1932
3 Replies

7. Shell Programming and Scripting

Sed delete blank lines upto first pattern match

Hi Im trying to do the following in sed. I want to delete any blank line at the start of a file until it matches a pattern and then stops. for example: Input output: I have got it to work within a range of two patterns with the following: sed '/1/,/pattern/{/^]*$/d}' The... (2 Replies)
Discussion started by: duonut
2 Replies

8. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

9. Shell Programming and Scripting

Help with ksh-to read ip file & append lines to another file based on pattern match

Hi, I need help with this- input.txt : L B white X Y white A B brown M Y black Read this input file and if 3rd column is "white", then add specific lines to another file insert.txt. If 3rd column is brown, add different set of lines to insert.txt, and so on. For example, the given... (6 Replies)
Discussion started by: prashob123
6 Replies

10. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies
ALTER 
GROUP(7) PostgreSQL 9.2.7 Documentation ALTER GROUP(7) NAME
ALTER_GROUP - change role name or membership SYNOPSIS
ALTER GROUP group_name ADD USER user_name [, ... ] ALTER GROUP group_name DROP USER user_name [, ... ] ALTER GROUP group_name RENAME TO new_name DESCRIPTION
ALTER GROUP changes the attributes of a user group. This is an obsolete command, though still accepted for backwards compatibility, because groups (and users too) have been superseded by the more general concept of roles. The first two variants add users to a group or remove them from a group. (Any role can play the part of either a "user" or a "group" for this purpose.) These variants are effectively equivalent to granting or revoking membership in the role named as the "group"; so the preferred way to do this is to use GRANT(7) or REVOKE(7). The third variant changes the name of the group. This is exactly equivalent to renaming the role with ALTER ROLE (ALTER_ROLE(7)). PARAMETERS
group_name The name of the group (role) to modify. user_name Users (roles) that are to be added to or removed from the group. The users must already exist; ALTER GROUP does not create or drop users. new_name The new name of the group. EXAMPLES
Add users to a group: ALTER GROUP staff ADD USER karl, john; Remove a user from a group: ALTER GROUP workers DROP USER beth; COMPATIBILITY
There is no ALTER GROUP statement in the SQL standard. SEE ALSO
GRANT(7), REVOKE(7), ALTER ROLE (ALTER_ROLE(7)) PostgreSQL 9.2.7 2014-02-17 ALTER GROUP(7)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy