An XARGS question
Todd Zullinger
tmz at pobox.com
Tue Jul 18 20:04:51 UTC 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael Yep wrote:
> That did not seem to work. Is this correct ?
>
> [root at localhost ~]# lastb -ai |fgrep "Jul 18" |awk '{print $10
> }'|sort|uniq|xargs grep -i {} /root/BLACKLIST
> grep: 222.234.108.77: No such file or directory
> grep: 83.15.73.34: No such file or directory
The -i is misplaced in this example. You'd want to use it after xargs
instead of after grep for it to do what you want. (Though you might
also want to use -i with grep to have it search case-insensitively.)
The xargs manpage states that the -i option is deprecated and you
should use -I{} instead. The {} is a string, you can use what you
wish as the string to the -I option, so a more readable example might
be:
... | xargs -Iip grep ip blacklist
- --
Todd OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
If everything seems to be going well, you have obviously overlooked
something.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.
iG0EARECAC0FAkS9PuMmGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1pXwwCg7gB2AVZLymRQweEvtKss/spRn0wAniyHmWvj
oCdWg+qbMMe5bSdg+8ut
=hbem
-----END PGP SIGNATURE-----
More information about the fedora-list
mailing list