| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
sed -f <(sed -r 's|.*\t(.*)|/\1\t/d|' file1) file2
This assuming that file2 is also tab delimited and does not have an IP followed by a tab in the variable data
On November 4, 2014 5:26:49 PM EET, "Tim Chase [email protected] [sed-users]" <[email protected]> wrote:
>On 2014-11-04 05:01, [email protected] [sed-users] wrote:
>> Maybe I should have given a little more info or the more realistic
>> issue.
>
>You know what they say, GIGO :-) Give an incomplete example, you'll
>get answers that don't actually solve your issues.
>
>> file1 is actually a list of know exceptions. The format is given
>> below and is tab delimited but I can squash to a single space ...
>>
>> icmp snmp ssh
>> N N N hostname 10.10.10.10
>
>So if I understand correctly, you're only interested in the last
>field of this file.
>
>> I then have file2, a "seedfile", Im basically trying to remove the
>> know exceptions from the seed file. Its format is
>>
>> 10.101.101.12 hostname Router (some other variable data)
>
>Then you want to filter this file based on the first tab-delimited
>column, excluding those items found in that first file. I think the
>following would do the trick:
>
> grep -vf <(sed '1d;s/.*\t\(.*\)/^\1\t/;s/\./\\./g' exceptions.txt)
> seedfile.txt
>
>This uses a bashism of <([command]) to create a FIFO. If you use
>another shell that doesn't support it, you can just pipe those
>results to a file, use it, then delete it:
>
> sed '1d;s/.*\t\(.*\)/^\1\t/;s/\./\\./g' exceptions.txt > bad_ips.txt
> grep -vf bad_ips.txt seedfile.txt
> rm bad_ips.txt
>
>This does assume that *both* files are tab-delimited.
>
>-tim
>
>
>
>
>
>------------------------------------
>Posted by: Tim Chase <[email protected]>
>------------------------------------
>
>--
>
>------------------------------------
>
>Yahoo Groups Links
>
>
>
--
Sent from my FairPhone. Please excuse my brevity.
[Non-text portions of this message have been removed]