Script needs to move one file to another directory; can't move it without its parent directory tree












0














In a bash script, I have:



TEMPPATH="/tmp/directory"

BACKUPPATH="/backup/path"


I'm trying to move one file using:



mv $TEMPPATH/file $BACKUPPATH/file


I want to move the file from /tmp/directory/file to /backup/path/file, but instead it ends up in /backup/path/tmp/directory/file. I've tried adding and removing trailing slashes from the destination, and excluding the filename from the destination (just using the destination directory). I've searched and find a lot of methods for moving lots of files in a directory, but I only want to move one.



========



EDIT: here is the script section that causes the problem. It's part of a script that backs up WordPress folders and databases. Note: if you are wondering why I'm not just zipping the files directly to the backup location, it's because I'm writing to Keybase. If you haven't used Keybase, since i/o to and from it is so slow, my goal was to zip files locally then move the file after zipping is complete.



#back up the WordPress folder and move over to backup location
echo Compressing site files
zip -r --quiet $TEMPPATH/$DATEFORM-$SITE.wp-content.zip .
echo Moving site zip file to Keybase
#mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE/$DATEFORM-$SITE.wp-content.zip
# ---------> this mv command works as expected:
mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE

#back up the WordPress database, compress, move to backup location and clean up
echo Exporting database
/usr/local/bin/wp db export $TEMPPATH/$DATEFORM-$SITE.sql --all-tablespaces --single-transaction --quick --lock-tables=false --allow-root --skip-themes --skip-plugins
echo Compressing database
zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
# ---------> this is the way the script was originally written -- maybe this cat method was used to prevent the same problem I am having?
# cat $TEMPPATH/$DATEFORM-$SITE.sql | zip > $TEMPPATH/$DATEFORM-$SITE.sql.zip
echo Moving sql zip file to Keybase
# ---------> this is the mv command that results in the directory tree being copied over to the destination
mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
echo Removing tmp file
rm $TEMPPATH/$DATEFORM-$SITE.sql









share|improve this question




















  • 4




    Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
    – Andy Dalton
    Dec 16 at 20:54








  • 1




    What's the output of type mv?
    – jimmij
    Dec 16 at 20:56










  • @jimmij, type mv returns mv is /bin/mv
    – sshanky
    Dec 17 at 5:21












  • 1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
    – sudodus
    Dec 17 at 7:23
















0














In a bash script, I have:



TEMPPATH="/tmp/directory"

BACKUPPATH="/backup/path"


I'm trying to move one file using:



mv $TEMPPATH/file $BACKUPPATH/file


I want to move the file from /tmp/directory/file to /backup/path/file, but instead it ends up in /backup/path/tmp/directory/file. I've tried adding and removing trailing slashes from the destination, and excluding the filename from the destination (just using the destination directory). I've searched and find a lot of methods for moving lots of files in a directory, but I only want to move one.



========



EDIT: here is the script section that causes the problem. It's part of a script that backs up WordPress folders and databases. Note: if you are wondering why I'm not just zipping the files directly to the backup location, it's because I'm writing to Keybase. If you haven't used Keybase, since i/o to and from it is so slow, my goal was to zip files locally then move the file after zipping is complete.



#back up the WordPress folder and move over to backup location
echo Compressing site files
zip -r --quiet $TEMPPATH/$DATEFORM-$SITE.wp-content.zip .
echo Moving site zip file to Keybase
#mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE/$DATEFORM-$SITE.wp-content.zip
# ---------> this mv command works as expected:
mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE

#back up the WordPress database, compress, move to backup location and clean up
echo Exporting database
/usr/local/bin/wp db export $TEMPPATH/$DATEFORM-$SITE.sql --all-tablespaces --single-transaction --quick --lock-tables=false --allow-root --skip-themes --skip-plugins
echo Compressing database
zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
# ---------> this is the way the script was originally written -- maybe this cat method was used to prevent the same problem I am having?
# cat $TEMPPATH/$DATEFORM-$SITE.sql | zip > $TEMPPATH/$DATEFORM-$SITE.sql.zip
echo Moving sql zip file to Keybase
# ---------> this is the mv command that results in the directory tree being copied over to the destination
mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
echo Removing tmp file
rm $TEMPPATH/$DATEFORM-$SITE.sql









share|improve this question




















  • 4




    Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
    – Andy Dalton
    Dec 16 at 20:54








  • 1




    What's the output of type mv?
    – jimmij
    Dec 16 at 20:56










  • @jimmij, type mv returns mv is /bin/mv
    – sshanky
    Dec 17 at 5:21












  • 1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
    – sudodus
    Dec 17 at 7:23














0












0








0







In a bash script, I have:



TEMPPATH="/tmp/directory"

BACKUPPATH="/backup/path"


I'm trying to move one file using:



mv $TEMPPATH/file $BACKUPPATH/file


I want to move the file from /tmp/directory/file to /backup/path/file, but instead it ends up in /backup/path/tmp/directory/file. I've tried adding and removing trailing slashes from the destination, and excluding the filename from the destination (just using the destination directory). I've searched and find a lot of methods for moving lots of files in a directory, but I only want to move one.



========



EDIT: here is the script section that causes the problem. It's part of a script that backs up WordPress folders and databases. Note: if you are wondering why I'm not just zipping the files directly to the backup location, it's because I'm writing to Keybase. If you haven't used Keybase, since i/o to and from it is so slow, my goal was to zip files locally then move the file after zipping is complete.



#back up the WordPress folder and move over to backup location
echo Compressing site files
zip -r --quiet $TEMPPATH/$DATEFORM-$SITE.wp-content.zip .
echo Moving site zip file to Keybase
#mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE/$DATEFORM-$SITE.wp-content.zip
# ---------> this mv command works as expected:
mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE

#back up the WordPress database, compress, move to backup location and clean up
echo Exporting database
/usr/local/bin/wp db export $TEMPPATH/$DATEFORM-$SITE.sql --all-tablespaces --single-transaction --quick --lock-tables=false --allow-root --skip-themes --skip-plugins
echo Compressing database
zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
# ---------> this is the way the script was originally written -- maybe this cat method was used to prevent the same problem I am having?
# cat $TEMPPATH/$DATEFORM-$SITE.sql | zip > $TEMPPATH/$DATEFORM-$SITE.sql.zip
echo Moving sql zip file to Keybase
# ---------> this is the mv command that results in the directory tree being copied over to the destination
mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
echo Removing tmp file
rm $TEMPPATH/$DATEFORM-$SITE.sql









share|improve this question















In a bash script, I have:



TEMPPATH="/tmp/directory"

BACKUPPATH="/backup/path"


I'm trying to move one file using:



mv $TEMPPATH/file $BACKUPPATH/file


I want to move the file from /tmp/directory/file to /backup/path/file, but instead it ends up in /backup/path/tmp/directory/file. I've tried adding and removing trailing slashes from the destination, and excluding the filename from the destination (just using the destination directory). I've searched and find a lot of methods for moving lots of files in a directory, but I only want to move one.



========



EDIT: here is the script section that causes the problem. It's part of a script that backs up WordPress folders and databases. Note: if you are wondering why I'm not just zipping the files directly to the backup location, it's because I'm writing to Keybase. If you haven't used Keybase, since i/o to and from it is so slow, my goal was to zip files locally then move the file after zipping is complete.



#back up the WordPress folder and move over to backup location
echo Compressing site files
zip -r --quiet $TEMPPATH/$DATEFORM-$SITE.wp-content.zip .
echo Moving site zip file to Keybase
#mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE/$DATEFORM-$SITE.wp-content.zip
# ---------> this mv command works as expected:
mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE

#back up the WordPress database, compress, move to backup location and clean up
echo Exporting database
/usr/local/bin/wp db export $TEMPPATH/$DATEFORM-$SITE.sql --all-tablespaces --single-transaction --quick --lock-tables=false --allow-root --skip-themes --skip-plugins
echo Compressing database
zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
# ---------> this is the way the script was originally written -- maybe this cat method was used to prevent the same problem I am having?
# cat $TEMPPATH/$DATEFORM-$SITE.sql | zip > $TEMPPATH/$DATEFORM-$SITE.sql.zip
echo Moving sql zip file to Keybase
# ---------> this is the mv command that results in the directory tree being copied over to the destination
mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
echo Removing tmp file
rm $TEMPPATH/$DATEFORM-$SITE.sql






shell-script shell ubuntu mv






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 17 at 5:40

























asked Dec 16 at 20:39









sshanky

11




11








  • 4




    Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
    – Andy Dalton
    Dec 16 at 20:54








  • 1




    What's the output of type mv?
    – jimmij
    Dec 16 at 20:56










  • @jimmij, type mv returns mv is /bin/mv
    – sshanky
    Dec 17 at 5:21












  • 1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
    – sudodus
    Dec 17 at 7:23














  • 4




    Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
    – Andy Dalton
    Dec 16 at 20:54








  • 1




    What's the output of type mv?
    – jimmij
    Dec 16 at 20:56










  • @jimmij, type mv returns mv is /bin/mv
    – sshanky
    Dec 17 at 5:21












  • 1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
    – sudodus
    Dec 17 at 7:23








4




4




Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
– Andy Dalton
Dec 16 at 20:54






Welcome! What you have works for me. Are you sure that you didn't misspell on of the variables in your script? Do any of your paths contain spaces?
– Andy Dalton
Dec 16 at 20:54






1




1




What's the output of type mv?
– jimmij
Dec 16 at 20:56




What's the output of type mv?
– jimmij
Dec 16 at 20:56












@jimmij, type mv returns mv is /bin/mv
– sshanky
Dec 17 at 5:21






@jimmij, type mv returns mv is /bin/mv
– sshanky
Dec 17 at 5:21














1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
– sudodus
Dec 17 at 7:23




1. It is a good idea to double-quote the variables, for example "$DATEFORM"; 2. Furthermore, it is a good idea to use curly brackets to mark the end of a variable, when it is directly followed by some character (except whitespace) or another variable, for example `"${DATEFORM}-${SITE}.sql.zip"
– sudodus
Dec 17 at 7:23










1 Answer
1






active

oldest

votes


















0














I tried your example and it works as expected - see output below.
What mv version do you use and on what system? And a piece of advice, to avoid any special characters (e.g. names with spaces) doing unexpected things I recommend quoting your variables and you can drop file name from the target: mv "$TEMPPATH/file" "$BACKUPPATH/".



Example from the question:



$ tree /tmp/directory
/tmp/directory
└── file

0 directories, 1 file
$ tree /backup
/backup
└── path

1 directory, 0 files
$ TEMPPATH="/tmp/directory"
$ BACKUPPATH="/backup/path"
$ mv $TEMPPATH/file $BACKUPPATH/file
$ tree /tmp/directory
/tmp/directory

0 directories, 0 files
$ tree /backup
/backup
└── path
└── file

1 directory, 1 file


Still cannot reproduce:



$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path

1 directory, 1 file
$ TEMPPATH=/tmp/test
$ DATEFORM=some
$ SITE=example
$ BACKUPPATH=/backup/path
$ zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
$ mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path
└── example

1 directory, 2 files





share|improve this answer























  • How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
    – sshanky
    Dec 17 at 5:24










  • I added the actual script above in case that helps.
    – sshanky
    Dec 17 at 5:40










  • I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
    – Evolter
    Dec 17 at 14:37












  • I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
    – sshanky
    Dec 17 at 17:41











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489379%2fscript-needs-to-move-one-file-to-another-directory-cant-move-it-without-its-pa%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I tried your example and it works as expected - see output below.
What mv version do you use and on what system? And a piece of advice, to avoid any special characters (e.g. names with spaces) doing unexpected things I recommend quoting your variables and you can drop file name from the target: mv "$TEMPPATH/file" "$BACKUPPATH/".



Example from the question:



$ tree /tmp/directory
/tmp/directory
└── file

0 directories, 1 file
$ tree /backup
/backup
└── path

1 directory, 0 files
$ TEMPPATH="/tmp/directory"
$ BACKUPPATH="/backup/path"
$ mv $TEMPPATH/file $BACKUPPATH/file
$ tree /tmp/directory
/tmp/directory

0 directories, 0 files
$ tree /backup
/backup
└── path
└── file

1 directory, 1 file


Still cannot reproduce:



$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path

1 directory, 1 file
$ TEMPPATH=/tmp/test
$ DATEFORM=some
$ SITE=example
$ BACKUPPATH=/backup/path
$ zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
$ mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path
└── example

1 directory, 2 files





share|improve this answer























  • How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
    – sshanky
    Dec 17 at 5:24










  • I added the actual script above in case that helps.
    – sshanky
    Dec 17 at 5:40










  • I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
    – Evolter
    Dec 17 at 14:37












  • I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
    – sshanky
    Dec 17 at 17:41
















0














I tried your example and it works as expected - see output below.
What mv version do you use and on what system? And a piece of advice, to avoid any special characters (e.g. names with spaces) doing unexpected things I recommend quoting your variables and you can drop file name from the target: mv "$TEMPPATH/file" "$BACKUPPATH/".



Example from the question:



$ tree /tmp/directory
/tmp/directory
└── file

0 directories, 1 file
$ tree /backup
/backup
└── path

1 directory, 0 files
$ TEMPPATH="/tmp/directory"
$ BACKUPPATH="/backup/path"
$ mv $TEMPPATH/file $BACKUPPATH/file
$ tree /tmp/directory
/tmp/directory

0 directories, 0 files
$ tree /backup
/backup
└── path
└── file

1 directory, 1 file


Still cannot reproduce:



$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path

1 directory, 1 file
$ TEMPPATH=/tmp/test
$ DATEFORM=some
$ SITE=example
$ BACKUPPATH=/backup/path
$ zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
$ mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path
└── example

1 directory, 2 files





share|improve this answer























  • How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
    – sshanky
    Dec 17 at 5:24










  • I added the actual script above in case that helps.
    – sshanky
    Dec 17 at 5:40










  • I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
    – Evolter
    Dec 17 at 14:37












  • I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
    – sshanky
    Dec 17 at 17:41














0












0








0






I tried your example and it works as expected - see output below.
What mv version do you use and on what system? And a piece of advice, to avoid any special characters (e.g. names with spaces) doing unexpected things I recommend quoting your variables and you can drop file name from the target: mv "$TEMPPATH/file" "$BACKUPPATH/".



Example from the question:



$ tree /tmp/directory
/tmp/directory
└── file

0 directories, 1 file
$ tree /backup
/backup
└── path

1 directory, 0 files
$ TEMPPATH="/tmp/directory"
$ BACKUPPATH="/backup/path"
$ mv $TEMPPATH/file $BACKUPPATH/file
$ tree /tmp/directory
/tmp/directory

0 directories, 0 files
$ tree /backup
/backup
└── path
└── file

1 directory, 1 file


Still cannot reproduce:



$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path

1 directory, 1 file
$ TEMPPATH=/tmp/test
$ DATEFORM=some
$ SITE=example
$ BACKUPPATH=/backup/path
$ zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
$ mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path
└── example

1 directory, 2 files





share|improve this answer














I tried your example and it works as expected - see output below.
What mv version do you use and on what system? And a piece of advice, to avoid any special characters (e.g. names with spaces) doing unexpected things I recommend quoting your variables and you can drop file name from the target: mv "$TEMPPATH/file" "$BACKUPPATH/".



Example from the question:



$ tree /tmp/directory
/tmp/directory
└── file

0 directories, 1 file
$ tree /backup
/backup
└── path

1 directory, 0 files
$ TEMPPATH="/tmp/directory"
$ BACKUPPATH="/backup/path"
$ mv $TEMPPATH/file $BACKUPPATH/file
$ tree /tmp/directory
/tmp/directory

0 directories, 0 files
$ tree /backup
/backup
└── path
└── file

1 directory, 1 file


Still cannot reproduce:



$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path

1 directory, 1 file
$ TEMPPATH=/tmp/test
$ DATEFORM=some
$ SITE=example
$ BACKUPPATH=/backup/path
$ zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql
$ mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE
$ tree /tmp/test /backup/
/tmp/test
└── some-example.sql
/backup/
└── path
└── example

1 directory, 2 files






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 17 at 14:34

























answered Dec 16 at 23:02









Evolter

1614




1614












  • How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
    – sshanky
    Dec 17 at 5:24










  • I added the actual script above in case that helps.
    – sshanky
    Dec 17 at 5:40










  • I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
    – Evolter
    Dec 17 at 14:37












  • I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
    – sshanky
    Dec 17 at 17:41


















  • How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
    – sshanky
    Dec 17 at 5:24










  • I added the actual script above in case that helps.
    – sshanky
    Dec 17 at 5:40










  • I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
    – Evolter
    Dec 17 at 14:37












  • I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
    – sshanky
    Dec 17 at 17:41
















How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
– sshanky
Dec 17 at 5:24




How strange. I don't understand what I'm doing wrong. I did try dropping the filename from the target as suggested.
– sshanky
Dec 17 at 5:24












I added the actual script above in case that helps.
– sshanky
Dec 17 at 5:40




I added the actual script above in case that helps.
– sshanky
Dec 17 at 5:40












I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
– Evolter
Dec 17 at 14:37






I think it isn't fault of the mv command - there must be something changing the variable used to specify the target. Maybe try printing the command (echo mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE) or related variables (or log to a file echo "$BACKUPPATH/$SITE" >> /tmp/log) every few lines.
– Evolter
Dec 17 at 14:37














I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
– sshanky
Dec 17 at 17:41




I made some changes as recommended and now I am getting the file to move properly, though the filename when extracted is simply "-". Perhaps there is something wrong with the way the variable is stored. Thanks everyone for your input. Learned lots.
– sshanky
Dec 17 at 17:41


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489379%2fscript-needs-to-move-one-file-to-another-directory-cant-move-it-without-its-pa%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre