[NTLUG:Discuss] Script question
Bob Byron
bbyron at radit.com
Fri Jan 4 16:15:53 CST 2002
You might give something like this a try:
rm domains.*.3
filename=`ls domains.*.2 | cut -d '.' -f 1-2`
mv ${filename}.2 ${filename}.3
Then repeat for the other files. Be careful not to delete something
you do not intend to delete.
Bob
----- Original Message -----
From: "Rick Matthews" <Rick at Matthews.net>
To: "Discuss at Ntlug. Org" <discuss at ntlug.org>
Sent: Friday, January 04, 2002 8:18 AM
Subject: [NTLUG:Discuss] Script question
> Would someone please help me over another "hump"? I'm still learning...
>
> I maintain the current version and 3 previous versions of the file
> "domains". The files are all in the same directory and the file name
> includes a unique date/time stamp and a version number. For example:
>
> domains.2002-01-04_050500.0
> domains.2002-01-02_052515.1
> domains.2002-01-01_043025.2
> domains.2001-12-30_050500.3
>
> '0' is the current version and '3' is the oldest.
>
> When a new file is created I want to "age" the files and create an open
> slot for a new "0" file (3 goes away, 2 becomes 3, 1 becomes 2, and 0
> becomes 1). I don't know the date/time stamps, so this is what I tried
> in my script:
>
> mv -f /archive/domains.*.2 /archive/domains.*.3
> mv -f /archive/domains.*.1 /archive/domains.*.2
> mv -f /archive/domains.*.0 /archive/domains.*.1
>
> The asterisk apparently acts as a wildcard during the file selection
> part of the command, but it is acting as a literal in the renaming
> porting of the command (I end up with files named domains.*.3).
>
> How can I rewrite this to accomplish the task?
>
> Thanks in advance!
>
> Rick Matthews
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list