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

Re: keeping the two latest files on a folder



On 10/13/09, Jeff D <fixedored@gmail.com> wrote:
> On Tue, 13 Oct 2009, Israel Garcia wrote:
>
>> Hi List,
>>
>> It's a simple  question but difficult to me :-).
>>
>> How can I delete all files on a folder /xxxx but keeping only the two
>> latest (newest)  files?
>>
> how about something like this to start:
> for file in $(ls -tA | egrep -v "$(ls -tA |head -n 2)") ; do if [ -f $file
> ] ; then echo "do a rm of $file"  ;fi ; done
Hi, jeff

Thanks for your answer., but doesn't work either :-(

regards,
Israel.
>
> --
> 8 out of 10 Owners who Expressed a Preference said Their Cats Preferred
> Techno.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
>
>


-- 
Regards;
Israel Garcia


Reply to: