Ask a Question related to SCO, Design and Development.
-
Sinisa #1
How to keep only 5 most recent files in certain folder
Hi,
I am trying to make a script that would run every couple hours and purge all
files in certain folder except last five files (most recent).
Files are being added to that folder constantly.
Can you help me ?
Thanks
Sinisa Guest
-
Function Open recent files in file menu doesn't show
When I try to open recent files from file menu there is no opportunity to choose it? I've installed ID 2.0.2 CE on Win 2000 again and it's the same.... -
How include IDD files in My Recent Documents on XP Start Menu?
..IDD files (Windows, 2.0) do not show up with other files in the My Recent Documents submenu on the XP Start Menu. Any way to change that? ... -
Lacking recent files in 'File' menu
The list of recent files in the 'Files' menu is static and inactive. It simply states 'Recent File' (greyed out). I am using acrobat standard... -
Open Recent Files in CS
Any reason Illustrator CS doesn't seem to hold an updated list of recent files? On start-up Open Recent Files in the file menu always defaults to a... -
Unable To Open "Recent Files"
I've seen this discussed before, but since the Forum Search Engine does not seem to be working, I'll ask it again: I am unable to open files from the... -
Roger Cornelius #2
Re: How to keep only 5 most recent files in certain folder
Sinisa wrote:
Here's one solution:>
> Hi,
>
> I am trying to make a script that would run every couple hours and purge all
> files in certain folder except last five files (most recent).
> Files are being added to that folder constantly.
>
> Can you help me ?
cd /whereever
n=5 # save $n most recent
set -- `/bin/ls -t`
if test $# -gt $n
then
shift $n
/bin/rm -f "$@"
fi
--
Roger Cornelius [email]racpop@tenzing.org[/email]
Roger Cornelius Guest
-
Richard Howlett #3
Re: How to keep only 5 most recent files in certain folder
Sinisa wrote:
Adapted from the standard way in .procmailrc to keep the latest n files in a> Hi,
>
> I am trying to make a script that would run every couple hours and purge all
> files in certain folder except last five files (most recent).
> Files are being added to that folder constantly.
backup directory where n is 5 to satisfy your criteria:
rm -f dummy `ls -t |sed -e 1,5d`
The reference to dummy is to ensure rm always has at least one filename as a
parameter.
--
Richard Howlett
[email]newsgroups@howie.org.uk[/email]
Mail to "newsgroups" will be rejected.
Mail to my forename will not.
Richard Howlett Guest
-
Dan Skinner #4
Re: How to keep only 5 most recent files in certain folder
Scott McMillan <smcm@usa.net> wrote in message news:<a6t6kvcsqnap44h71plkpu31kccn1hu9ug@4ax.com>. ..
head -5 will give you the first or newest 5.> On Wed, 20 Aug 2003 01:37:52 GMT, scriptOmatic
> <ScriptOmatic@ChironComputing.Com> wrote:
>>> >Sinisa wrote:> >> >>
> >> Hi,
> >>
> >> I am trying to make a script that would run every couple hours and purge all
> >> files in certain folder except last five files (most recent).
> >> Files are being added to that folder constantly.
> >>
> >> Can you help me ?
> >>
> >> Thanks
> >use
> >/bin/ls -tr "-t" for sort by time
> > "-r" for sort reverse
> >
> >the top 5 lines will be the 5 NEWEST files, e.g:
> Actually, using the -r option on SCO Openserver would place the OLDEST
> files first. Just using -t will place the NEWEST files first. Since
> the OP didn't even hint at the flavor/version of his/her system but
> posted to the c.u.s.m NG I'm assuming he/she is using either SCO
> Openserver or Unixware.
>>> >
> >
> >/bin/ls -tr | head -5
> >
> >should do it
>
> Scott McMillan
I'd suggest
rm `ls -t * | tail +6`
you can pretty it up and handle the null set and figure out what to
do with directories if they exist.
Regards…Dan.
Dan Skinner Guest



Reply With Quote

