From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23606 invoked by alias); 19 Aug 2015 22:32:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20434 Received: (qmail 835 invoked from network); 19 Aug 2015 22:32:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Subject: =?UTF-8?Q?list_last_modified_files?= From: =?UTF-8?Q?rooom?= To: zsh-users@zsh.org Mime-Version: 1.0 Message-ID: <6ac3d5e6.2de49d01.55d4fc3c.9415a@prokonto.pl> Date: Wed, 19 Aug 2015 23:59:24 +0200 X-Originator: 5.172.247.243 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, I'm=20trying=20to=20write=20a=20function=20which=20lists=2010=20most=20re= cent=20files=20from=20given=20sets=20(not=20only=20directories),=20someth= ing=20like=20trivial=20`alias=20lt=3Dls=20-lat=20|=20head=20-n=2010`,=20b= ut=20better. It=20should=20work=20like lt=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20#=20list=2010=20recent=20files=20from=20. lt=20dir=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20#=20list=2010=20recent=20files=20from=20dir/ lt=20dir1=20file1=20dir2/file*=20dir3=20=20=20#=20list=2010=20recent=20fi= les=20from=20a=20given=20sum=20of=20inputs Here=20is=20my=20solution=20so=20far,=20which=20I=20think=20is=20overcomp= licated=20and=20iffy: lt()=20{ls=20-Adlt=20--=20"${^@:-.}"(Ne:'[[=20-d=20$REPLY=20]]=20&&=20rep= ly=3D($REPLY/*(DNomon[1,10]))=20||=20true':)=20|=20head=20-n=2010} Here=20how=20it=20should=20work: For=20each=20argument=20check=20if=20it=20is=20directory,=20and=20in=20th= at=20case=20return=2010=20most=20recent=20modified=20files=20from=20that=20= directory,=20then=20add=20other=20arguments=20to=20the=20list=20(files)=20= and=20ignore=20all=20non-file=20arguments=20(N).=20After=20all=20pass=20g= enerated=20set=20to=20the=20'ls'=20command=20which=20sorts=20it=20on=20mo= dification=20time=20and=20finally=20pass=20to=20'head=20-n=2010'. Several=20question: 1.=20First=20of=20all=20I=20cannot=20understand=20why=20do=20I=20need=20a= =20command=20"true"=20to=20list=20properly=20arguments=20which=20are=20=20= not=20directories.=20I=20can=20put=20there=20other=20command=20as=20well=20= like=20'echo=20>/dev/null',=20but=20'true'=20is=20simplest=20I=20could=20= find=20(for=20example=20':'=20doesn't=20work).=20From=20my=20basic=20unde= rstanding=20no=20command=20should=20be=20needed=20to=20properly=20handle=20= 'lt=20file'. 2.=20I=20would=20like=20to=20get=20rid=20of=20external=20`head=20-n=2010`= =20command=20and=20use=20glob=20qualifiers=20instead,=20but=20as=20you=20= can=20see=20there=20are=20already=20two=20nested=20qualifier=20lists,=20a= nd=20I=20can't=20see=20a=20way=20to=20put=20one=20more=20after=20all=20of= =20that=20just=20to=20take=20(om[1,10]). 3.=20When=20I=20run=20it=20with=20only=20non-existing=20files=20like=20'l= t=20nonexistingfile'=20then=20it=20prints=20single=20dot=20'.'.=20I=20wou= ld=20prefer=20to=20print=20error=20from=20'ls'=20command=20like=20"ls:=20= cannot=20access...".=20Note=20that=20I=20cannot=20remove=20(N)=20qualifie= r=20because=20zsh=20steps=20in=20with=20its=20own=20errors=20-=20I=20want= =20zsh=20to=20pass=20argument=20to=20'ls'=20as=20it=20is=20in=20case=20it= =20cannot=20find=20files. Hope=20it's=20not=20too=20long, thanks=20in=20advance