Re: An XARGS question

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

 



On Tue, Jul 18, 2006 at 02:31:52PM -0500, Michael Yep wrote:
> Hello
> 
> Is there a way to have xargs or perhaps another tool take a list from
> stdin and put it somewhere besides the last argument?
> 
> Say if i want to get all the offending IPs (bad logins) for a given day
> then i want to take that list and see if its in a file called blacklist
> 
> lastb -ai |fgrep "Jul 18" |awk '{print $10 }'|sort|uniq | xargs grep ???
> blacklist
> 
> where ??? would be where the stdin goes

Others have directed you toward "xargs -i", which is correct,
but in this particular example, you can do something simpler,

	lastb -ai |fgrep "Jul 18" |awk '{print $10 }'|sort|uniq \
	|fgrep -x -f - blacklist
 
where "-f -" reads the list of patterns from standard input, and
"-x" matches the whole line, to eliminate false hits.  Under other
circumstances, "-w" might be appropriate.

This has the virtue of invoking fgrep once and processing all addresses
in parallel.

Regards,

	Bill Rugolsky

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux