From: Jonathan Ryshpan jonrysh@pacbell.net Subject: Re: tail for a list of files To: users@lists.fedoraproject.org Message-ID: 1520171408.2173.42.camel@pacbell.net Content-Type: multipart/alternative; boundary="=-PuQtDYwItgjfcLx2Crff"
--=-PuQtDYwItgjfcLx2Crff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit
On Sat, 2018-03-03 at 11:15 -0500, bruce wrote:
Trying to figure out how to do a single line cmd (it should be possible right??) to do a tail -5 for a list of files???
I thought I could combine find with exec/xargs and tail to generate the list of files/tail data.. But couldn't figure out the syntax..
find /foo -name "*dog.dat ... tail -5 << obviously not correct. but what would work?
I think the easy way is $ find /foo -name "*dog.dat" | xargs tail -n5 or am I missing something?
I created 4 pdf files using 'touch 123.pdf' through '126.pdf'
find . -name "*.pdf" | tail -n 2
does not 'find' the files in canonical order: it outputs 124.pdf and 126.pdf
Neither does .... | xargs tail -n 2
Trying: tail -n 2 $(find . -name "*.pdf") gives: ==> ./125.pdf <==
==> ./123.pdf <==
==> ./124.pdf <==
==> ./126.pdf <==
NOT in order and ignores the 'tail -n 2'
tail -n 2 $(find . -name "*.pdf"| sort) gives the files in order, but ignores the tail count.
HOWEVER this works: find . -name "*.pdf" | sort | tail -n 2 ./125.pdf ./126.pdf
Geoff