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

Re: keeping the two latest files on a folder



On Tue, Oct 13, 2009 at 03:35:19PM EDT, Håkon Alstadheim wrote:
> Israel Garcia skrev:
>> 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?
>>
>>   
> untested, run it with 'echo' in front first to test:
> rm $(ls -rt | sed '1,2d')

sed rocks...!

CJ


Reply to: