Is there a database built into the base system
Ernie Luzar
luzar722 at gmail.com
Sat Apr 8 17:00:18 UTC 2017
RW via freebsd-questions wrote:
> On Fri, 07 Apr 2017 21:34:17 -0400
> Ernie Luzar wrote:
>
> he op I have been reading all the replies. I know that awk
>> exists, but never used it because the man page is so hard to
>> understand. I like this manual but this online version is hard to
>> navigate.
>
> I were you I'd start by looking for a shorter tutorial with some good
> examples.
>
> What's nice about awk is the way it's optimized for use in pipelines.
> You can run a series of action (blocks of code) against each line, each
> action can be preceded by an optional test. There also a BEGIN{} block
> where you can do initialization and an END{} block where you can tie
> things up. If you don't want to use it that way you can simply put all
> the code inside BEGIN{}.
>
> Beyond this unusual structure it's a pretty straightforward scripting
> language.
Here is my first try at using awk to Read every record in the input
file and drop duplicates records from output file.
This what the data looks like.
/etc >cat /ip.org.sorted
1.121.136.228;
1.186.172.200;
1.186.172.210;
1.186.172.218;
1.186.172.218;
1.186.172.218;
1.34.169.204;
101.109.155.81;
101.109.155.81;
101.109.155.81;
101.109.155.81;
104.121.89.129;
/etc >cat /root/bin/ipf.table.awk.dup
#! /bin/sh
file_in="/ip.org.sorted"
file_out="/ip.no-dups"
awk '{ in_ip = $1 }'
END { (if in_ip = prev_ip)
next
else
prev_ip > $file_out
prev_ip = in_ip
} $file_in
When I run this script it just hangs there. I have to ctrl/c to break
out of it. What is wrong with my awk command?
More information about the freebsd-questions
mailing list