On 29/11/2007, Alex Samad <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 28, 2007 at 10:16:45AM +1100, Amos Shapira wrote:
> > On 28/11/2007, Alex Samad <[EMAIL PROTECTED]> wrote:
> > > Hi
> > >
> > >
> > > I have this commend which i use
> > >
> > > find -mindepth 2 -type d -exec bash -c 'ls -l "{}" | tail -n 2' \;
> > >
> > > I have tried to format the -exec option with out the bash -c, but I can't
> > > figure out a way to escape off the |
> >
> > If you don't want bash to interpret the 'ls -l "{}" | tail -n 2' then
> > which program is supposed to interpret the pipeline symbol?
>
> I wanted | to be interpreted by the exec command, silly me I just presumed it
> started a sh, but thinking about it know, it probably doesn't which is why it
> can't process the |
>
> I want to show the last 2 files in the directory
For each directory under the current one?
It looks like you got it right with the command above. I can't think
of anything much more efficient short of maybe converting it using
"find2perl" and using Perl all the way through.
If you explain what you need these two files for then maybe we can
find a more efficient way to do that (I'm averse to use of -exec but
it looks like from your "mission statement" there isn't much more that
can be done).
--Amos
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html