Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

move/rename script 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello

im doing a manual procedure everytime i want to move created daily backup files. i want it move to a different directory and rename those files with (current) date extension.i.e., say - fr /home/file01 to /home/aaa/file01.(mm/dd/yy) and would be nice if i be informed thru email that it is successful.

gracias
 
hello,

use this script if you are comfortable.

ext=`date +%d%m%C%y`
for i in /home/*
do
fn=`echo $i | cut -f4 -d '/'`
mv $i /home/aaa/$fn.$ext
done


Note: it will move all the files from the home directory. If you want to move only specific files, give it in the "for loop" or store all the files in a separate directory then use this script.

Use mail or mailx to send mail after completion.
Take care.

- Raj.
 
The syntax for mail in the script, as your last line would be:

echo "Text in your message" | mail -s "Subject Line" address@mail.whatever
 
hello,

are these lines correct?

fn=`echo $i | cut -f4 -d '/'`
mv $i /home/aaa/$fn.$ext

i'm getting:

Usage: mv [-i | -f] [--] src target
or: mv [-i | -f] [--] src1 ... srcN directory

thanks.
 
Try sticking a "print $i" in there and see what you get. IBM Certified -- AIX 4.3 Obfuscation
 
i put print $i and got this:

/home/sample/backup
/home/sample/backup.cron

but, when you check destination directory, i got this:

root pts/0 $ ls -l sample2
total 16
-rwxrwxrwx 1 root system 2226 Jun 06 09:40 sample.
-rwxrwxrwx 1 root system 221 Jun 06 10:01 sample.date+%d%m%C%y

'seems not working...
 
i put print $i and got this:

/home/sample/backup
/home/sample/backup.cron

but, when you check destination directory, i got this:

root pts/0 $ ls -l sample2
total 16
-rwxrwxrwx 1 root system 2226 Jun 06 09:40 sample.
-rwxrwxrwx 1 root system 221 Jun 06 10:01 sample.date+%d%m%C%y

'seems not working...
 
Did you use "back ticks" (lowercase of the "~" sign) in this line, the result looks like you have normal single quotes instead?

ext=`date +%d%m%C%y`
IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
Just to throw this out...

double quotes "" will let certain characters through to the shell, such as $, so you can use variable names inside them.

single quotes '' let nothing through, everything is literal.

backticks `` are something else entirely. The enclosed command is run and the result is stored in the variable.

BTW, cool sig aixmurderer. =) IBM Certified -- AIX 4.3 Obfuscation
 
Yegolev - seeing that some of us here seems to think I don't deserve my certs I thought the sig may just calm the poor fellow down. :)

Some people.... wonder what he would say if I had to list all my other certs, diplomas and qualifications too.... IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
I see them as similar to a high-school diploma or a college degree. They help you get a nice job but in the end how much of what you used to pass the test is something you use daily at work? A lot of what I do is not covered in the textbooks, but admittedly it's largely application of basic skills. The things I learned in order to get my certs are either forgotten or are just basic elements of larger tasks, like basic commands, elementary troubleshooting, etc. Not to say certs are useless, but they do have a certain context. IBM Certified -- AIX 4.3 Obfuscation
 
Quite agreed, the cert exams covers very basic stuff, mainly something a junio sysadmin should know. The problem is you learn the stuff at that time, but rarely use it again unless you set up a new machine.

That's exactly where I went now, a new pSeries and AIX5.1, all new hardware and OSLevel to me, predictably some issues came up. Funny thing is, struggled a bit with basic stuff, while the more advanced stuff like sendmail, db2, MQSeries config etc. didn't cause me any grief. Probably because I work more at that level. IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top