Grepping exact pattern and deleting the rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grepping exact pattern and deleting the rows
# 22  
Old 05-03-2016
Quote:
Originally Posted by MadeInGermany
Note that there were two questions, one in post#1 and one in post#5.
Notice I am making clear what question I am providing an alternative suggestion in Perl.

Post #5 is a bit unambiguous to my understanding and the modification done by Don to my suggestion will not do.

Quote:
Originally Posted by am24
Hi Ravinder/Zaxxon

Thank you so much for the quick response. Both of your codes worked fine. I have got the expected output. Thanks Zaxxon for reminding me about the Field Separator.

Just to understand, the '$' in the code indicates the end of the column right ? Please correct me if i am wrong.

What if i want to ignore any row that contains '513' in the mid position of the column ?

Say like below:
31513514 28720 23310 11840 6140 2330 27180 15960 15340 15340 0

in the above 513 is in positions 3 to 5. How can i ignore this particular row?

Regards,
am24
First, the so mentioned request is only for 513, the modification would include 515. The intend might or might not be the same that post 1.
Second, mid position could be any position within the column except being part of the start or end of the column, since the numbers do not align to an exact mid point. Or it could be just 31451314
# 23  
Old 05-03-2016
Hi Don / Aia ,

Thanks for your time on this.

Yes I have asked two questions one is in post#1 and the other in post#5.

Perl is not available for me. However i have got the results for both the questions using the codes suggested by Rudi and Ravinder.

Regards,
am24
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To search exact pattern

Hi, I need to search the exact pattern in a file file.txt AUS.txt|AUS.chk NZ.txt|NZ.ch I am getting the result as AUS.txt|AUS.chk with below code but i need only AUS.txt to be printed grep AUS.txt file.txt CODE tags also for data files (8 Replies)
Discussion started by: rohit_shinez
8 Replies

2. Shell Programming and Scripting

Printing next two lines from a file after grepping a specific pattern

Hi I have a file like # vi require.txt 1,BANK,Read blocks that cycle. yellow Read blocks. 2,ACCOUNT,Finished Red Finished . 3,LOAN, pipe white pipe 4,PROFIT,Resolve. black Resolve Am using like cat require.txt | grep -w ACCOUNTThe output I get is (8 Replies)
Discussion started by: Priya Amaresh
8 Replies

3. Shell Programming and Scripting

To find the exact pattern

My Input : Hi editor this is the exact pattern which we looking for the previous patternmatch My code: awk '/pattern/ { print a } { a = $0 }' Current output : exact previous (3 Replies)
Discussion started by: Roozo
3 Replies

4. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

5. UNIX for Advanced & Expert Users

merge two tab delimited file with exact same number of rows in unix/linux

Hi I have two tab delimited file with different number of columns but same number of rows. I need to combine these two files in such a way that row 1 in file 2 comes adjacent to row 1 in file 1. For example: The content of file1: field1 field2 field3 a1 a2 a3 b1 b2 b3... (2 Replies)
Discussion started by: mary271
2 Replies

6. Shell Programming and Scripting

how to finding the exact pattern

I have a output like below: A1 B2 C1 D3 A12 B4 A14 I am trying to find A1 by using grep grep -i "A1" But I got (4 Replies)
Discussion started by: anupdas
4 Replies

7. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

8. Shell Programming and Scripting

Searching a pattern in file and deleting th ewhole line containing the pattern

Hi All, Please can someone assist in the script I have made that searches a pattern in a file and delete the whole line containing the pattern. #!bin/sh # The pattern that user want to add to the files echo "Enter the pattern of the redirect" read value # check if the user has... (1 Reply)
Discussion started by: Shazin
1 Replies

9. Shell Programming and Scripting

Grepping for Exact Strings

ok, apparently this is a very difficult question to answer based on my searches on google that came up fruitless. what i want to do is grep through a file for words that match a specified string. but the thing is, i keep getting all words in the file that have the string in them. say for... (27 Replies)
Discussion started by: SkySmart
27 Replies

10. Shell Programming and Scripting

Grepping 1 line above and below pattern

I have a pattern:: xldn3176bap>arj SOCRATES_MAIN_LNX | grep " FA " 10/04/2007 21:01 10/04/2007 21:01 FA 1776752/1 1 I want the line above this line and the line below it too. Can anyone tell me how it can be done? - iAm4Free (4 Replies)
Discussion started by: iAm4Free
4 Replies
Login or Register to Ask a Question