Remove lines that match string at end of column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove lines that match string at end of column
# 1  
Old 03-27-2012
Remove lines that match string at end of column

I have this:

Code:
301205          0000030000041.49000000.00                   2011111815505     908       
301205          0000020000029.10000000.00                   2011111815505     962       
301205          0000010000027.56000000.00                   2011111815505     3083      
312291          0000020000032.30000000.00                   2012020230120     33        
312291          0000030000048.45000000.00                   2012020230120     256       
312291          -00005-000080.75-00000.00                   2012020230120     256       
805223          0000030000049.65000000.00                   20120301203       8         
805223          0000030000062.73000000.00                   20120301203       15        
805223          0000030000057.45000000.00                   20120301203       33

I want to remove the lines that end with 30120 but only in the 3rd column (only marked red).

I tried these:

Code:
awk '$3 !~30120 ' rassales.txt > rassales2.txt

removed any 30120 in 3rd column not just lines ending with
Code:
awk '$3 !=30120 ' rassales.txt > rassales2.txt

only complete match (removed nothing)

Am I close?Smilie
# 2  
Old 03-27-2012
Only a $-sign away Smilie
Code:
awk '$3 !~ /30120$/' infile

This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 03-27-2012
Thanks!

How the hell do people get so good at regex? Well, how do eight year old's play guitar so well that they become famous for that matter...

---------- Post updated at 11:10 AM ---------- Previous update was at 11:00 AM ----------

Quote:
Originally Posted by Scrutinizer
Only a $-sign away Smilie
Code:
awk '$3 !~ /30120$/' infile


Looks like it removed this too:

Code:
805223          0000030000049.65000000.00                   20120301203       8         
805223          0000030000062.73000000.00                   20120301203       15

I want to keep those

---------- Post updated at 11:18 AM ---------- Previous update was at 11:10 AM ----------

NEVERMIND. I was checking the results incorrectly. Smilie Smilie
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 having older end time

Hi, In my bash script I want to add a code which remove all entries older than x days. To simplify this problem, I have divided into 3 parts. (2 parts are done looking answer for 3rd part.) To find the latest log date - Done Latest_Time=`find . -name '*.tps' -exec sed '/endTime/!d; s/{//;... (3 Replies)
Discussion started by: Agoyals1986
3 Replies

2. Linux

How to remove lines without a particular string in either column?

I have a file that looks like this: DIP-27772N DIP-18408N refseq:NP_523941 DIP-23436N|refseq:NP_536784 DIP-23130N|refseq:NP_652017 DIP-22958N|refseq:NP_651195 DIP-20072N|refseq:NP_724597 DIP-22928N|refseq:NP_569972 DIP-22042N|refseq:NP_536744|uniprotkb:P54622... (4 Replies)
Discussion started by: Syeda Sumayya
4 Replies

3. Shell Programming and Scripting

Conversion if 1st column is match (awk '{s+=$1} END

Hi im trying to add numbers, got no problem with it im using awk '{s+=$1} END {print s, "MB"}', but what if the numbers are like mention below. who will i add them 2000 KB 1 MB Answer: 2001 Desired: 2000 KB 1 MB Answer: 3000 (4 Replies)
Discussion started by: invinzin21
4 Replies

4. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

5. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

6. Shell Programming and Scripting

BASH: remove digits from end of string

Hi there, im sure this is really simple but i have some strings like this e1000g123001 e1000g0 nge11101 nge3and i want to create two variables ($DRIVER and $INSTANCE). the first one containing the alpha characters that make up the first part of the string, e.g. e1000g or nge and the... (9 Replies)
Discussion started by: rethink
9 Replies

7. Shell Programming and Scripting

Awk: Remove comma at the end of the string

Hi i had String like UID: ABC345QWE678GFK345SA90, LENGTH 32 when I used awk ' FS, {print $1}' prints ABC345QWE678GFK345SA90, how can i getrid of that coma at the end of the string. Thanks in advance.. (14 Replies)
Discussion started by: Reddy482
14 Replies

8. UNIX for Dummies Questions & Answers

Regular Expression - match 'b' that follows 'a' and is at the end of a string

Hi, I'm struggling with a regex that would match a 'b' that follows an 'a' and is at the end of a string of non-white characters. For example: Line 1: aba abab b abb aab bab baa I can find the right strings but I'm lacking knowledge of how to "discard" the bits that precede bs.... (2 Replies)
Discussion started by: machinogodzilla
2 Replies

9. Shell Programming and Scripting

Remove / at the end of a string if it exists

Hey guys, Can sed or another command be used to examine a path such as /home/test/blah/blahand check to see if the last character is a "/" and if so remove it So this is what should happen: /home/test/blah/blahnothing happens, this is ok /home/test/blah/blah/the "/" at the end is... (6 Replies)
Discussion started by: tret
6 Replies

10. Shell Programming and Scripting

How to remove plank spaces at the end of lines

Hello friends, I want to remove blank spaces at the end of lines. I use sed command to do this but it is not working correctly. sed ‘s/ $//’ file_name Can some body tell me what is the proper way to remove blank spaces at the end of a limes. Thanks, Mahesh Fernando. (3 Replies)
Discussion started by: maheshsri
3 Replies
Login or Register to Ask a Question