What makes you say "does NOT work" ?  That is, what error message are you
getting?  Or how does the output you get differ from what you expect?

Expanding on what Michael wrote, using the command below is similar to
`tail -n1 myfiles*` but ensures `tail` only works on files ( not folders ),
is able to handle filenames with spaces, and can handle large numbers of
files.

$ find ./. -maxdepth 1 -type f -name 'myfiles*' -print0 | xargs -0 tail -n 1

Regards,
- Robert

On Sun, May 5, 2024 at 10:30 AM Michael Ewan <michaelewa...@gmail.com>
wrote:

> As previously noted, "tail -n 1 myfiles*" works.  If you still want a Bash
> command line, here are a couple of options.  The benefit of the first one
> is that tail does not print the names of the files.
>
> $ for f in myfiles*; do tail -1 $f; done
>
> $ find myfiles* | xargs tail -n 1    # but this is totally like tail -n 1
> myfiles*
>
>
>
> On Sun, May 5, 2024 at 8:00 AM American Citizen <website.read...@gmail.com
> >
> wrote:
>
> > Hi:
> >
> > Does anyone know the bash command for getting the tail command to work
> > correctly for a range of files, using the wild card character?
> >
> > tail -1 myfiles*
> >
> > does NOT work, but I do want the tail to run over the matched files in
> > myfiles*
> >
> > Currently I am using
> >
> > ls myfiles* | sed "s/^/tail -1 /" > tmp ; bash tmp ; rm tmp
> >
> > but this is cumbersome.
> >
> > Thanks for showing a simple answer
> >
> > Randall
> >
> >
> >
>

Reply via email to