Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Reply to this topicStart new topic
> Copy Or Rename Script, copy or rename script
post Nov 21 2003, 04:56 AM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 1
Joined: 21-November 03
Member No.: 1,838

Hello I am rather new to Linux and I need a script or utility to copy or rename a file that changes frequently to succesive file names.. that maybe i can call from cron to be done at certain times
As an example I have file and want it copied or renamed to
and next time it is copied to check to see what last name is and name it next higher number in succession.. ie and

Am I asking for too much? sounds pretty simple just not familiar enough with linux script files.

Maybe it doesnt have to be a script can i add options to end of a command like cp that will handle this for me?
Go to the top of the page
+Quote Post
post Nov 21 2003, 09:02 AM
Post #2

Its GNU/

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151

A script is the way to go ... it can be done several ways. First, would a date-time e better than a number? If you are going to run the script once per day or less, you could use the date like so (or maybe Either is doable ... what's best for you?

Here is a simple script i named


# This does the math for the filename and stores the result
# for future use in a file called test.num.  This file is
# designed to be in the directory the other files reside in
if [ -f test.num ]; then
 a=`cat test.num`

let "a = $a + 1"
echo $a > test.num

# This copies the file to when you run
# the script.  If you also want to remove the old
# and start with a new file, remove the # from the last line

cp list-"$a".xxx
#echo >

If you save this script to a text file and make it executable (chmod 755, it will copy a file named to (the next time it is run it will copy to, etc.) and if you remove the # from the last line it will blankout to start it over from a blank file.

Johnny Hughes
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 24th June 2018 - 04:00 PM