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!

Moving and Renaming a file

Status
Not open for further replies.

blx

MIS
Oct 9, 2002
23
GB
Hi
Attached is a small script that's driving me mad!!
I want to compress a file (using gzip - which I have done), I then want to rename the file using the mv command but add the date and time to the filename from the variables I've declared at the top of the script.
Is there an easy way that I can do this using the mv command or does anyone know of another way? In the script below, it's the second 'mv' line in bold that isn't working.
Thanks in Advance

#!/bin/sh
datestamp=`date +%D" "%T`
epmgrlog=$DBDIR/epmgrlog.log
wepmgr stop
mv $DBDIR/epmgrlog $DBDIR/epmgrlog.log
gzip $epmgrlog
mv $DBDIR/$gzipped $DBDIR/$epmgrlog/$datestamp
wepmgr start
 
mv $DBDIR/$gzipped "$DBDIR/$epmgrlog/$datestamp" vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
A filename can not contain a &quot;/&quot;.

datestamp=`date +%D&quot; &quot;%T|sed s/&quot;\/&quot;/./g`

regards Gregor

Gregor.Weertman@mailcity.com
 
Sorry guys,
still no joy. The mv command works, but the problem seems to be when I try to add the date to the end of it. Any other suggestions
 
my suggestion for your problem

datestamp=`date +%m%d%y&quot;-&quot;%H%M%S`
mv $DBDIR/$gzipped $DBDIR/$epmgrlog&quot;-&quot;$datestamp

I hope I have understood your problem correctly.

bye
Jürgen

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top