Re: keeping the two latest files on a folder
On Wed, Oct 14, 2009 at 04:43:04PM +1030, Matthew Smith wrote:
> Quoth Håkon Alstadheim at 14/10/09 16:37...
>> Due to all the positive feed-back, I actually tested the "ls -rt"-bit,
>> and sure enough, the 'r' makes ls list the newest files _last_, so you
>> DON'T want 'r'. This makes the correct command:
>>
>> rm $(ls -t | sed '1,2d')
>
> I thought this looked like an interesting recipe, so I tried it. (With
> echo, I hasten to add.)
>
> I get a listing of every file (and directory) in the directory, but all
> on one line.
>
> All the sed seems to do is to convert the multiple spaces used to format
> ls -t into single spaces.
try: ls $PARAMETERS | cat
'ls' defaults to a single-column format when the output is a pipe.
--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend
Reply to: