[NTLUG:Discuss] Script question: give me the next sequential filename....
Michael Farnham
mfarnham at acm.org
Mon Mar 31 10:23:19 CST 2003
On Monday 31 March 2003 09:41, Jack Snodgrass wrote:
> I need to create a log. It needs to be called
> makefile.yymmdd-x where
> makefile.yymmdd can be done with something like
> makefile.`date +DATE: '%y%m%d`
>
> ...now the catch... the first time I run this today, I want
> makefile.030331-1
> the next time I want
> makefile.030331-2
> and then
> makefile.030331-3
> etc.
>
Something like this should work
#!/bin/bash
declare -i n
pattern=makefile.`date +'%y%m%d'`-
n=`ls -1 $pattern | wc -l`
n=n+1
pattern=$pattern$n
echo $pattern
exit 0
HTH
Mike Farnham
--
You've got to be honest; if you can fake that, you've got it made.
-- George Burns
More information about the Discuss
mailing list