Sponsored Content
Top Forums Shell Programming and Scripting Locate and remove lines with sed Post 302727007 by rwuerth on Monday 5th of November 2012 01:30:00 PM
Old 11-05-2012
I like sed a lot, but I see ugliness in trying to get values from one file and use them to delete values in another file using sed.

I think:
Code:
grep -vFf data2delete file2

may work well.

It returns the following:

Code:
A          2915.0  7325.01212 75   2   5248969 78 46
A          2915.0  7325.012 7 75   2   5216571 80 44
A          2555.0  7255.013 9 75   1   2163071 78 59
A          2555.0  7255.013 5 75   1  -3162871 77 52
A          2571.0  7260.01410 75   1  -2204470 77 41
A          2571.0  7260.014 6 75   2   5182570 77 37
A          2557.0  7255.013 9 75   1   5153071 77 67
A          2557.0  7255.013 5 75   1  -3162871 77 42
A          2895.0  7255.011 7 75   1  -3203071 77 41
A          2895.0  7255.011 1 75   1  -2174671 77 56
A          2901.0  7245.01211 75   1   4184671 79 56
A          2901.0  7245.012 4 75   1   3195171 77 43
A          2559.0  7255.013 9 75   2   5255268 77 42
A          2559.0  7255.013 5 75   2   9309067 76 30
A          2575.0  7260.014 6 75   2   5162670 76 40
A          2575.0  7260.01410 75   2   9279767 77 41
A          2899.0  7245.01211 75   1  -2152872 77 62
A          2899.0  7245.012 4 75   1  -2142771 78 45
A          2899.0  7255.011 7 75   1   4142771 77 55
A          2899.0  7255.011 1 75   1  -2214770 77 42

This User Gave Thanks to rwuerth For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed or Awk to remove specific lines

I have searched the forum for this - forgive me if I missed a previous post. I have the following file: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah alter table "informix".esc_acct add constraint (foreign key (fi_id) references "informix".fi ... (5 Replies)
Discussion started by: Shoeless_Mike
5 Replies

2. Shell Programming and Scripting

Using sed to remove lines where field is empty

I was just looking at this post: https://www.unix.com/shell-programming-scripting/22893-delete-multiple-empty-lines.html. and I am looking to achieve the same with sed. So the idea is to delete lines from a file where a certain field has no value. Inputfile: EMID MMDDYY HOURS JOB EMNAME 0241... (4 Replies)
Discussion started by: figaro
4 Replies

3. Shell Programming and Scripting

How to remove lines before and after with awk / sed ?

Hi guys, I need to remove the pattern (ID=180), one line before and four lines after. Thanks. (5 Replies)
Discussion started by: ashimada
5 Replies

4. Shell Programming and Scripting

using sed to remove lines

Can somebody explain why my sed command is not working. I do the folloinwg: Generates a binary file to /tmp/x1.out /usr/lib/sa/sa2 -s 4:00 -e 8:00 -i 3600 -A -o /tmp/x1.out decodes the file (no problem so far) sar -f /tmp/x1.out When I do this it does not appear to delete the... (4 Replies)
Discussion started by: BeefStu
4 Replies

5. Shell Programming and Scripting

What's the command to remove empty lines with sed?

3 10 20 10 100 100 10000 Output: 3 10 20 10 100 100 10000 ---------- Post updated at 07:59 AM ---------- Previous update was at 07:56 AM ---------- sed '/^$/d' file doesn't work. (8 Replies)
Discussion started by: cola
8 Replies

6. Shell Programming and Scripting

SED to remove a line above and lines below.

:confused:Hi All, I need help on removing lines in a text file. Sample file : When there is a match ip for IPAddress in my `cat ip.out`, proceed delete line above until string "Comp" is found. Thank you very much. ---------- Post updated at 12:56 AM ---------- Previous update was... (4 Replies)
Discussion started by: chiewming
4 Replies

7. UNIX for Dummies Questions & Answers

How to remove certain lines using sed?

Hi I have the following kind of line sin my file . print ' this is first'. print ' this is firs and next ' ' line continuous '. -- this is entire print line. print ' this is first and next ' ' line continuous and' 'still there now over'. -- this 3lines together a single print line. ... (5 Replies)
Discussion started by: Sivajee
5 Replies

8. Shell Programming and Scripting

How to remove certain lines using sed?

Hi, I am new to unix and i started some scripting recently. Please go through the following script i wrote. #!/bin/sh file='path../tfile' file1='path../tfile1' rmfile='path../test2' C1=1 C2=1 exec 3< $file1 while read LINE1; do read LINE2 <&3 a=$LINE1 b=`expr $LINE2 - 1` ... (1 Reply)
Discussion started by: Subbu123
1 Replies

9. Shell Programming and Scripting

sed to remove next 15 lines after pattern in Solaris

Team, I am trying to use sed to delete 15 lines, after pattern patch, which includes the pattern as well in Solaris. I used the below command, as we do it Linux, but it's not working as expected in Solaris. I am getting the error as "garbled".sed '/\/table/,+15d' status.html sed: command... (8 Replies)
Discussion started by: Nagaraj R
8 Replies

10. Shell Programming and Scripting

How to remove repetitive lines in a file with sed?

Hello, My goal is the make all x times repeated lines into a single line. I need to attain the expected output with sed -i , I need to overwrite the MyFile MyFile: Hello World Welcome Hello World Welcome Back This is my test Expected output: Hello World Welcome Welcome Back This is... (6 Replies)
Discussion started by: baris35
6 Replies
Mail::Milter::Module::ConnectMatchesHostname(3pm)	User Contributed Perl Documentation	 Mail::Milter::Module::ConnectMatchesHostname(3pm)

NAME
Mail::Milter::Module::ConnectMatchesHostname - milter to accept/reject connecting hosts matching regex(es) SYNOPSIS
use Mail::Milter::Module::ConnectMatchesHostname; my $milter = new Mail::Milter::Module::ConnectMatchesHostname; my $milter2 = &ConnectMatchesHostname; # convenience $milter2->set_message('Connecting hostname %H looks like a dynamic address'); DESCRIPTION
This milter module rejects any connecting host whose hostname contains one of a group of built-in patterns that match the IP address of the connecting host. This is normally used to detect dynamic pool addresses. Currently the following patterns embedded in the hostname are considered matching, where 10.11.12.13 is the IPv4 address of the connecting host. In the following cases, the string must be preceded by a non-digit character or otherwise must be at the start of the hostname. 010.011.012.013. (optionally without internal dots, or with - in place of .) 013.012.011.010. (optionally with - in place of .) 10.11.12.13. (optionally without internal dots, or with - in place of .) 13.12.11.10. (optionally with - in place of .) 0A0B0C0D (hexadecimal, ignoring case) More specific patterns are anticipated to be added in the future. Because of this, if you use ConnectMatchesHostname, pay attention to this perldoc manual page when updating to a newer version of Mail::Milter. One final note. ISPs can and do use "dynamic-looking" reverse DNS entries for what they consider to be legitimate server addresses. This is not ideal, and may require embedding this module in a Chain set to "accept_break" with regular expressions; for example: my $milter = new Mail::Milter::Chain( &ConnectRegex( '.fooisp.com$', )->accept_match(1); &ConnectMatchesHostname, )->accept_break(1); METHODS
new() Creates a ConnectMatchesHostname object. set_message(MESSAGE) Sets the message used when rejecting connections. This string may contain the substring %H, which will be replaced by the matching hostname, and/or the substring %A, which will be replaced by the matching IP address. This method returns a reference to the object itself, allowing this method call to be chained. BUGS
In Sendmail 8.11 and 8.12, a milter rejection at "connect" stage does not allow the reply message to be set -- it simply becomes "not accepting messages". However, this module still attempts to set the reply code and message in the hope that this will be fixed. The implementation of this module could be much more efficient. AUTHOR
Todd Vierling, <tv@duh.org> <tv@pobox.com> SEE ALSO
Mail::Milter::Object perl v5.8.8 2004-02-26 Mail::Milter::Module::ConnectMatchesHostname(3pm)
All times are GMT -4. The time now is 03:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy