Re: tail for a list of files

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

 



On Sun, Mar 04, 2018 at 02:32:03PM -0800, Samuel Sieb wrote:
> On 03/04/2018 11:43 AM, bruce wrote:
> > 
> > I wanted to get the last X lines of each file from an input/wildcard
> > list of files !!
> > 
> 
> There were already at least two different solutions posted.
> 
> tail -n 5 $(find /foo -name "*dog.dat")
> find /foo -name "*dog.dat" -print0 | xargs -0  tail -n5

I'll add a third.  Difference is printing of the filename.
The two above depend on tail to print the name IF there
are multiple arguments.  If there is only one match by find
or if xargs' last group no filename will be printed.  This
could be avoided by adding /dev/null to tail's arg list.

The first solution above could exceed the system or shell's
maximum command line length.

ASolution where find prints the filename and calls a separate
tail for each file is:

  find /foo -type f -name "*dog.dat" -print -exec tail -n 5 {} ';'

Jon
-- 
Jon H. LaBadie                  jonfu@xxxxxxxxxx
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux