Re: keeping the two latest files on a folder



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')


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Client "daemon" for sorting e-mail via IMAP
    ... and tell him "move it to that folder there"? ... I'll clean up and post the script if anyone is interested. ... and may have trouble connecting to Gmail. ... subject of "unsubscribe". ...
    (Debian-User)
  • Re: Samba usershares & permissions problem
    ... folder inside my home dir and adding sharing. ... has permissions 644 and is owned by alan:alan. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)
  • Re: /home/user folder accidentally removed
    ... I recently installed Debian to my computer to have Linux experince, so it didn't have any important files. ... I just had a new user folder. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)
  • Re: keeping the two latest files on a folder
    ... How can I delete all files on a folder /xxxx but keeping only the two ... script or shell function to do it, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)
  • Re: wheezy konqueror - cannot download Adobe Flashplayer
    ... It is the easiest way to get the plugin ... folder. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... Trouble? ...
    (Debian-User)