Remove lines with Pattren Matching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove lines with Pattren Matching
# 1  
Old 08-10-2017
Remove lines with Pattren Matching

Hi ,

I need to remove the lines that matches the pattern
Code:
TABLEEXCLUDE *.AQ$_*_F ;

* is wildcard, it can be any word.

For example, I have following file:

Code:
TABLEEXCLUDE THOT.AQ$_PT_ADDR_CLEANUP_QTAB2_F ;
TABLEEXCLUDE THOT.AQ$_MICRO_SERVICE_QT_F ;
TEST
TABLEEXCLUDE THOT.AQ$_TEST_B ;
TABLEEXCLUDE THOT.AQ_T_F ;

I need o/p:

Code:
 TEST
 TABLEEXCLUDE THOT.AQ_T_F ;

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, sample output, and code segments (as required by forum rules.

Last edited by Don Cragun; 08-10-2017 at 04:09 PM.. Reason: Add CODE and ICODE tags.
# 2  
Old 08-10-2017
What operating system and shell are you using?

Is there some reason why grep with a basic regular expression:
Code:
grep -v 'TABLEEXCLUDE .*\.AQ\$_.*_F ;' file

doesn't work for you?

Why shouldn't the output be:
Code:
TEST
TABLEEXCLUDE THOT.AQ$_TEST_B ;
TABLEEXCLUDE THOT.AQ_T_F ;

? I don't see why the _B shown in red above should match the pattern you provided.

Update: Since you didn't use CODE tags in your post, we couldn't see that you want a leading <space> added to your output. Is this really required?

Last edited by Don Cragun; 08-10-2017 at 04:11 PM.. Reason: Add update.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lines matching a substring in a specific column

Dear group, I have following input text file: Brit 2016 11 18 12 00 10 1.485,00 EUR Brit 2016 11 18 12 00 10 142,64 EUR Brit 2016 11 18 12 00 10 19,80 EUR Brit 2016 11 18 12 00 10 545,00 EUR Brit 2016 11 18 12 00 10 6.450,00 EUR... (3 Replies)
Discussion started by: gfhsd
3 Replies

2. Shell Programming and Scripting

awk to combine all matching dates and remove non-matching

Using the awk below I am able to combine all the matching dates in $1, but I can not seem to remove the non-matching from the file. Thank you :). file 20161109104500.0+0000,x,5631 20161109104500.0+0000,y,2 20161109104500.0+0000,z,2 20161109104500.0+0000,a,4117... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Replace a string on specific lines which match a pattren

Hi Experts, I have a file which contains a pattern multiple times i.e. matchthispattren. If a line is matched with this pattern. I want a number in 1234567890 to 123456789 in that line. (Basically remove the last digit from that number. Please help. Thanks, Varun (1 Reply)
Discussion started by: varun22486
1 Replies

4. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

5. Shell Programming and Scripting

Insert lines above matching line with content from matching

Hi, I have text file: Name: xyz Gender: M Address: "120_B_C; ksilskdj; lsudlfw" Zip: 20392 Name: KLM Gender: F Address: "65_D_F; wnmlsi;lsuod;,...." Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value The Address value in quotes... (1 Reply)
Discussion started by: ysrini
1 Replies

6. Shell Programming and Scripting

Remove duplicate lines (the first matching line by field criteria)

Hello to all, I have this file 2002 1 23 0 0 2435.60 131.70 5.60 20.99 0.89 0.00 285.80 2303.90 2002 1 23 15 0 2436.60 132.90 6.45 21.19 1.03 0.00 285.80 2303.70 2002 1 23 ... (6 Replies)
Discussion started by: joggdial3000
6 Replies

7. Shell Programming and Scripting

compare two files and to remove the matching lines on both the files

I have two files and need to compare the two files and to remove the matching lines from both the files (4 Replies)
Discussion started by: shellscripter
4 Replies

8. Shell Programming and Scripting

Remove matching lines with list of strings

Hi, HP-UX gxxxxxxxc B.11.23 U ia64 3717505098 unlimited-user license I have a file with below pipe separated field values: xxx|xxx|abcd|xxx|xxx|xx xxx|xxx|abcd#123|xxx|xxx|xx xxx|xxx|abcd#345|xxx|xxx|xx xxx|xxx|pqrs|xxx|xxx|xx xxx|xxx|pqrs#123|xxx|xxx|xx The third field has values like... (6 Replies)
Discussion started by: Nanu_Manju
6 Replies

9. Shell Programming and Scripting

negate * with in pattren matching...

Hi Every one I have a file in the following manner... AAAAAA*PERFORM WRITEQ BBDFDD*PERFOMF WRITEQ FFFF *PERFOMF WRITEQ i want to find the lines which donot have * in 7th position.. I have tried this but some problem i think... grep '......*WRITEQ' INpFIle... any 6 chars not... (7 Replies)
Discussion started by: pbsrinivas
7 Replies

10. Shell Programming and Scripting

Problem with pattren Matching

I have a set of programs and there coressponding MAPSETs i tried grep on the all the programs and got the following out put from this i want to extract only the Program Name and Mapset name {i.e. the word in (' ') after MAPSET } There or some cases where u have no ( after MAPSET that need... (7 Replies)
Discussion started by: pbsrinivas
7 Replies
Login or Register to Ask a Question