Re: An XARGS question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 18, 2006 at 11:31:00PM +0200, Alexander Dalloz wrote:
> Even shorter:
> 
> lastb -ai | awk '/Jul 18/ {print $10}' | sort -u | fgrep -x -f - blacklist

Of course, in the way that I wrote it, if blacklist really only contains
IP addresses, and is not huge, then one should reverse the order:

	| fgrep -x -f blacklist

If blacklist is huge, and the output of the pipeline is not, or e.g., blacklist
has multiple fields, say IP address, reason for blacklisting, etc., and one
wants the whole record, then the order that I gave is useful.

To avoid false matches, one should either use -w, or put delimiters in the file,
and include them in the input patterns, e.g.,

lastb -ai | awk '/Jul 18/ {printf ":%s:\n", $10}' | sort -u | fgrep -f - blacklist

In really ugly situations, one wants to use (e)grep instead of fgrep, and one may
need to escape regex metacharacters like '.' in the input patterns.

Regards,

	Bill Rugolsky


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux