Date: Sat, 08 Apr 2017 13:00:15 -0400 From: Ernie Luzar <luzar722@gmail.com> To: RW <rwmaillists@googlemail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Is there a database built into the base system Message-ID: <58E9171F.3060405@gmail.com> In-Reply-To: <20170408145503.69ddf649@gumby.homeunix.com> References: <58E696BD.6050503@gmail.com> <69607026-F68C-4D9D-A826-3EFE9ECE12AB@mac.com> <58E69E59.6020108@gmail.com> <20170406210516.c63644064eb99f7b60dbd8f4@sohara.org> <58E6AFC0.2080404@gmail.com> <20170407001101.GA5885@tau1.ceti.pl> <20170407210629.GR2787@mailboy.kipshouse.net> <58E83E19.8010709@gmail.com> <20170408145503.69ddf649@gumby.homeunix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?58E9171F.3060405>