help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] latest


From: John McKown
Subject: Re: [Help-bash] latest
Date: Sun, 27 Nov 2016 18:28:36 -0600

On Sat, Nov 26, 2016 at 10:43 PM, Val Krem <address@hidden> wrote:

> Hi all,
>
> I am trying to fine  the latest 5 files in a given folder and count the
> number of rows in each  of files
>
> I used,
>
>
> ls  -1t | head -5.
>
> How do I pass these files to the command  wc -l?
>

​Two possibilities:

wc -l $(ls -1t | head -5)

or

ls -1t | head -5​ | xargs wc -l


​Personally, I tend to use the latter, unless the command to be executed
wants to communicate with me via stdin. That's because xargs reads all of
the stdin to create the command, so any read of stdin by the program
invoked by xargs gets an immediate EOF.


>
> Thank you in advance
>
>


-- 
Heisenberg may have been here.

Unicode: http://xkcd.com/1726/

Maranatha! <><
John McKown


reply via email to

[Prev in Thread] Current Thread [Next in Thread]