How to move files from one directory to a nested directory using SSH?
Clash Royale CLAN TAG#URR8PPP
I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.
shell rename
add a comment |
I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.
shell rename
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02
add a comment |
I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.
shell rename
I would like to know how to move all the files, not the folder or directory, to an existing folder or directory two levels down.
shell rename
shell rename
edited Jan 6 at 21:33
Rui F Ribeiro
39.6k1479132
39.6k1479132
asked Feb 5 '13 at 18:33
user31836user31836
61
61
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02
add a comment |
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02
add a comment |
2 Answers
2
active
oldest
votes
You'll want to use the find command.
find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory
Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.
If you need only files in the current directory, you can use the command:
find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
add a comment |
If you have zsh available, this is pretty simple. The pattern *
matches all files (including directories). To match only regular files, add the glob qualifier .
. Glob qualifiers are a zsh feature.
mv *(.) existing/subsubdirectory/
(Actually *
skips files whose name begins with a .
(“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D
inside the parentheses.)
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f63835%2fhow-to-move-files-from-one-directory-to-a-nested-directory-using-ssh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You'll want to use the find command.
find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory
Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.
If you need only files in the current directory, you can use the command:
find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
add a comment |
You'll want to use the find command.
find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory
Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.
If you need only files in the current directory, you can use the command:
find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
add a comment |
You'll want to use the find command.
find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory
Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.
If you need only files in the current directory, you can use the command:
find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir
You'll want to use the find command.
find . -type f -name "*" -print0 | xargs -0 -I mv ../backup_dir ; mv ../backup_dir ./new/directory
Note that I've moved the files to a directory to one directory up, to prevent find from being stuck in a loop finding the new files that you're moving. Then move the directory two levels down.
If you need only files in the current directory, you can use the command:
find . -type f -maxdepth 1 -name "*" -print0 | xargs -0 -I mv ../backup_dir
edited Feb 5 '13 at 22:34
Gilles
532k12810661594
532k12810661594
answered Feb 5 '13 at 20:46
StephanStephan
1,771714
1,771714
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
add a comment |
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
@uther - it's not always desirable to execute commands interactively, i.e. automated backup scripts on a cron job.
– Stephan
Feb 5 '13 at 23:00
add a comment |
If you have zsh available, this is pretty simple. The pattern *
matches all files (including directories). To match only regular files, add the glob qualifier .
. Glob qualifiers are a zsh feature.
mv *(.) existing/subsubdirectory/
(Actually *
skips files whose name begins with a .
(“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D
inside the parentheses.)
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
add a comment |
If you have zsh available, this is pretty simple. The pattern *
matches all files (including directories). To match only regular files, add the glob qualifier .
. Glob qualifiers are a zsh feature.
mv *(.) existing/subsubdirectory/
(Actually *
skips files whose name begins with a .
(“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D
inside the parentheses.)
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
add a comment |
If you have zsh available, this is pretty simple. The pattern *
matches all files (including directories). To match only regular files, add the glob qualifier .
. Glob qualifiers are a zsh feature.
mv *(.) existing/subsubdirectory/
(Actually *
skips files whose name begins with a .
(“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D
inside the parentheses.)
If you have zsh available, this is pretty simple. The pattern *
matches all files (including directories). To match only regular files, add the glob qualifier .
. Glob qualifiers are a zsh feature.
mv *(.) existing/subsubdirectory/
(Actually *
skips files whose name begins with a .
(“dot files”). This is probably not a concern here, but if you do need to move those as well, add a D
inside the parentheses.)
answered Feb 6 '13 at 1:28
GillesGilles
532k12810661594
532k12810661594
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
add a comment |
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
Guys, I appreciate your efforts. I got more than I bargained for. Because I'm new to using PUTTY, I was able to copy the files, but will keep the code you offered to try later when I'm more comfortable. Thanks again for all the help.
– user31836
Feb 8 '13 at 21:41
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f63835%2fhow-to-move-files-from-one-directory-to-a-nested-directory-using-ssh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Why do you need to use SSH, and presumably scp and sftp? Can you not get a shell on the remote server?
– George M
Feb 5 '13 at 21:02