Date: Fri, 23 Jul 1999 13:02:41 -0700 (PDT) From: Doug <Doug@gorean.org> To: Brendan Kosowski <brendan@bmk.com.au> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: bash question Message-ID: <Pine.BSF.4.05.9907231258120.27420-100000@dt011n65.san.rr.com> In-Reply-To: <Pine.BSF.3.96.990723234100.13264B-100000@garfield>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 24 Jul 1999, Brendan Kosowski wrote: > Is there a special character I can use in filenames to tell bash to > automatically increment a number within the filename when redirecting data > to the file. No. > eg. The first time I type "date > [filename]" I want bash to place the > date in a filename called date.001 > > Now, because date.001 already exists, the next time I type the same > command it should produce date.002, and so on.... I had to solve a similar problem with a perl script that I use to do a trashcan type deletion routine. Here's what I came up with in pseudo-code. All of these things are possible to do with bash scripting too. Good luck, Doug -- On account of being a democracy and run by the people, we are the only nation in the world that has to keep a government four years, no matter what it does. -- Will Rogers Does date.nnn exist? If yes split number off the end increment number new filename is date + new number If no new filename is date + 001 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9907231258120.27420-100000>