How do I move files and directories to the parent folder in Linux?
In Linux (Ubuntu), how do you move all the files and directories to the parent directory?
linux ubuntu file-management
add a comment |
In Linux (Ubuntu), how do you move all the files and directories to the parent directory?
linux ubuntu file-management
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39
add a comment |
In Linux (Ubuntu), how do you move all the files and directories to the parent directory?
linux ubuntu file-management
In Linux (Ubuntu), how do you move all the files and directories to the parent directory?
linux ubuntu file-management
linux ubuntu file-management
edited Nov 3 '11 at 11:47
slhck
159k47442465
159k47442465
asked Dec 27 '09 at 17:25
nekbaba
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39
add a comment |
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39
add a comment |
12 Answers
12
active
oldest
votes
find . -maxdepth 1 -exec mv {} .. ;
this will move hidden files as well.
You will get the message:
mv: cannot move `.' to `../.': Device or resource busy
when it tries to move .
(current directory) but that won't cause any harm.
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use-maxdepth 1
to be sure.
– ℝaphink
Dec 27 '09 at 17:36
1
Now it says: mv: cannot move./scripts' to
../scripts': Directory not empty
– nekbaba
Dec 27 '09 at 17:43
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
add a comment |
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
add a comment |
Type this in the shell:
mv *.* ..
That moves ALL the files one level up.
The character *
is a wildcard. So *.deb
will move all the .deb files, and Zeitgeist.*
will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, ..
indicates the parent directory.
To move everything including folders, etc, just use *
instead of *.*
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
You want*
not*.*
to include directories
– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
add a comment |
It can't be more simple than:
mv * ../
To also move hidden files:
mv /path/subfolder/{.,}* /path/
mv
is a command to move files, *
means all files and folders and ../
is the path to the parent directory.
add a comment |
In bash you can use
shopt -s dotglob
to make * match all files and move them simply by
shopt -s dotglob; mv * ..
This is not the best solution since the setting is permanent for the shell until you change it by
shopt -u dotglob
but I think it's good to know.
4
Call it in a subshell:(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.
– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
add a comment |
A method which causes no errors and works every time:
ls -1A . | while read -r file
do
mv "./${file}" ..
done
add a comment |
find . -maxdepth 2 -type f -exec mv {} .. ;
I used a variation of above to move all the files from subfolders into the parent.
I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.
eg.
/data/2001/file_1
/data/2002/file_2
/data/2003/file_3
add a comment |
Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use
mv * .[A-Za-z0-9]* ..
The .[A-Za-z0-9]*
part is to make sure you don't try to move .
or ..
along, which would fail.
add a comment |
It's simple to move all files and folders to the parent directory in Linux.
Go to that folder and use this command:
mv * /the full path
For example, if your files and folders are as follows:
/home/abcuser/test/1.txt
2.txt
3.jpg
4.php
1folder
2folder
Go to that folder via cd:
cd /home/abcuser/test
mv * /home/abcuser
All your files and folders will move to the abcuser folder (parent directory).
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,/the full path
does not work in Linux, you have to escape spaces with/the full path
.
– slhck
Nov 3 '11 at 11:47
add a comment |
There is no need to change directories. Just include * at the end of path:
mv /my/folder/child/* /my/folder/
Above only moves non hidden files. To move only hidden files use .*
mv /my/folder/child/.* /my/folder/
Above two can be combined in to one command:
mv /my/folder/child/{.,}* /my/folder/
Also see:
How to move all files including hidden files into parent directory via *
add a comment |
find -type f|while read line; do mv $line ${line##*/}; done
Thanks for contributing an answer. While this might work in simple scenarios, pipingfind
intowhile read
is a bad way to usefind
, and better answers have already been posted.
– Scott
Dec 13 '18 at 16:29
add a comment |
switch to sub directory and execute following command for copy or move files.
ex: a is parent directory and b is sub directory, we want to move/copy all files from b to a (sub directory to parent directory).
cd b
cp * ..
mv * ..
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f88202%2fhow-do-i-move-files-and-directories-to-the-parent-folder-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
12 Answers
12
active
oldest
votes
12 Answers
12
active
oldest
votes
active
oldest
votes
active
oldest
votes
find . -maxdepth 1 -exec mv {} .. ;
this will move hidden files as well.
You will get the message:
mv: cannot move `.' to `../.': Device or resource busy
when it tries to move .
(current directory) but that won't cause any harm.
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use-maxdepth 1
to be sure.
– ℝaphink
Dec 27 '09 at 17:36
1
Now it says: mv: cannot move./scripts' to
../scripts': Directory not empty
– nekbaba
Dec 27 '09 at 17:43
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
add a comment |
find . -maxdepth 1 -exec mv {} .. ;
this will move hidden files as well.
You will get the message:
mv: cannot move `.' to `../.': Device or resource busy
when it tries to move .
(current directory) but that won't cause any harm.
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use-maxdepth 1
to be sure.
– ℝaphink
Dec 27 '09 at 17:36
1
Now it says: mv: cannot move./scripts' to
../scripts': Directory not empty
– nekbaba
Dec 27 '09 at 17:43
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
add a comment |
find . -maxdepth 1 -exec mv {} .. ;
this will move hidden files as well.
You will get the message:
mv: cannot move `.' to `../.': Device or resource busy
when it tries to move .
(current directory) but that won't cause any harm.
find . -maxdepth 1 -exec mv {} .. ;
this will move hidden files as well.
You will get the message:
mv: cannot move `.' to `../.': Device or resource busy
when it tries to move .
(current directory) but that won't cause any harm.
edited Dec 27 '09 at 17:35
answered Dec 27 '09 at 17:29
John T
142k20292328
142k20292328
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use-maxdepth 1
to be sure.
– ℝaphink
Dec 27 '09 at 17:36
1
Now it says: mv: cannot move./scripts' to
../scripts': Directory not empty
– nekbaba
Dec 27 '09 at 17:43
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
add a comment |
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use-maxdepth 1
to be sure.
– ℝaphink
Dec 27 '09 at 17:36
1
Now it says: mv: cannot move./scripts' to
../scripts': Directory not empty
– nekbaba
Dec 27 '09 at 17:43
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
1
1
It will move all files from all subdirectories to the parent of the current directory, too. I'd use
-maxdepth 1
to be sure.– ℝaphink
Dec 27 '09 at 17:36
It will move all files from all subdirectories to the parent of the current directory, too. I'd use
-maxdepth 1
to be sure.– ℝaphink
Dec 27 '09 at 17:36
1
1
Now it says: mv: cannot move
./scripts' to
../scripts': Directory not empty– nekbaba
Dec 27 '09 at 17:43
Now it says: mv: cannot move
./scripts' to
../scripts': Directory not empty– nekbaba
Dec 27 '09 at 17:43
1
1
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
You must have a directory called scripts in your parent directory AND in your current directory. You will have to rename this one before you move it.
– ℝaphink
Dec 27 '09 at 17:44
1
1
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
It worked but you left one one very important bit of information - you must run this from the subdirectory. Also this will not delete the subdirectory itself so you must back up one directory and do a rmdir on the subdirectory.
– crafter
May 10 '16 at 16:50
add a comment |
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
add a comment |
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
add a comment |
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
answered Jan 26 '13 at 20:20
Ben Fransen
886189
886189
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
add a comment |
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
9
9
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
This does not move hidden file though
– Wavesailor
Sep 10 '15 at 10:51
1 liner:
(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
1 liner:
(cd ${ANDROID_NDK_HOME}/android-ndk-r14b/ && mv * ../)
– Dawid Drozd
Dec 7 '17 at 11:51
add a comment |
Type this in the shell:
mv *.* ..
That moves ALL the files one level up.
The character *
is a wildcard. So *.deb
will move all the .deb files, and Zeitgeist.*
will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, ..
indicates the parent directory.
To move everything including folders, etc, just use *
instead of *.*
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
You want*
not*.*
to include directories
– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
add a comment |
Type this in the shell:
mv *.* ..
That moves ALL the files one level up.
The character *
is a wildcard. So *.deb
will move all the .deb files, and Zeitgeist.*
will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, ..
indicates the parent directory.
To move everything including folders, etc, just use *
instead of *.*
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
You want*
not*.*
to include directories
– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
add a comment |
Type this in the shell:
mv *.* ..
That moves ALL the files one level up.
The character *
is a wildcard. So *.deb
will move all the .deb files, and Zeitgeist.*
will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, ..
indicates the parent directory.
To move everything including folders, etc, just use *
instead of *.*
Type this in the shell:
mv *.* ..
That moves ALL the files one level up.
The character *
is a wildcard. So *.deb
will move all the .deb files, and Zeitgeist.*
will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, ..
indicates the parent directory.
To move everything including folders, etc, just use *
instead of *.*
edited Jun 26 '18 at 7:09
robinCTS
4,00741527
4,00741527
answered Dec 27 '09 at 17:27
Gil
1112
1112
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
You want*
not*.*
to include directories
– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
add a comment |
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
You want*
not*.*
to include directories
– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
1
1
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
this didn't work with the dirs! or the hidden files
– nekbaba
Dec 27 '09 at 17:34
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
It works with dirs, at least for me.
– maaartinus
Jan 25 '11 at 21:21
4
4
You want
*
not *.*
to include directories– Chris S
Apr 19 '13 at 19:58
You want
*
not *.*
to include directories– Chris S
Apr 19 '13 at 19:58
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
Its a nice documentary
– BlackBurn027
Nov 17 '16 at 6:36
add a comment |
It can't be more simple than:
mv * ../
To also move hidden files:
mv /path/subfolder/{.,}* /path/
mv
is a command to move files, *
means all files and folders and ../
is the path to the parent directory.
add a comment |
It can't be more simple than:
mv * ../
To also move hidden files:
mv /path/subfolder/{.,}* /path/
mv
is a command to move files, *
means all files and folders and ../
is the path to the parent directory.
add a comment |
It can't be more simple than:
mv * ../
To also move hidden files:
mv /path/subfolder/{.,}* /path/
mv
is a command to move files, *
means all files and folders and ../
is the path to the parent directory.
It can't be more simple than:
mv * ../
To also move hidden files:
mv /path/subfolder/{.,}* /path/
mv
is a command to move files, *
means all files and folders and ../
is the path to the parent directory.
edited Dec 10 '17 at 11:44
answered Jul 16 '14 at 18:50
William Edwards
268313
268313
add a comment |
add a comment |
In bash you can use
shopt -s dotglob
to make * match all files and move them simply by
shopt -s dotglob; mv * ..
This is not the best solution since the setting is permanent for the shell until you change it by
shopt -u dotglob
but I think it's good to know.
4
Call it in a subshell:(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.
– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
add a comment |
In bash you can use
shopt -s dotglob
to make * match all files and move them simply by
shopt -s dotglob; mv * ..
This is not the best solution since the setting is permanent for the shell until you change it by
shopt -u dotglob
but I think it's good to know.
4
Call it in a subshell:(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.
– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
add a comment |
In bash you can use
shopt -s dotglob
to make * match all files and move them simply by
shopt -s dotglob; mv * ..
This is not the best solution since the setting is permanent for the shell until you change it by
shopt -u dotglob
but I think it's good to know.
In bash you can use
shopt -s dotglob
to make * match all files and move them simply by
shopt -s dotglob; mv * ..
This is not the best solution since the setting is permanent for the shell until you change it by
shopt -u dotglob
but I think it's good to know.
answered Jan 25 '11 at 21:33
maaartinus
1,56762037
1,56762037
4
Call it in a subshell:(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.
– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
add a comment |
4
Call it in a subshell:(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.
– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
4
4
Call it in a subshell:
(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.– Martin Ueding
Jan 26 '13 at 20:25
Call it in a subshell:
(shopt -s dotglob && mv * ..)
. That way, the option is only local to that subshell.– Martin Ueding
Jan 26 '13 at 20:25
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
Good answer - it's simple, includes hidden files and doesn't cause an error about copying '.' and '..'
– Daniel Howard
Nov 9 '17 at 13:06
add a comment |
A method which causes no errors and works every time:
ls -1A . | while read -r file
do
mv "./${file}" ..
done
add a comment |
A method which causes no errors and works every time:
ls -1A . | while read -r file
do
mv "./${file}" ..
done
add a comment |
A method which causes no errors and works every time:
ls -1A . | while read -r file
do
mv "./${file}" ..
done
A method which causes no errors and works every time:
ls -1A . | while read -r file
do
mv "./${file}" ..
done
answered Jul 25 '12 at 20:15
djhaskin987
23926
23926
add a comment |
add a comment |
find . -maxdepth 2 -type f -exec mv {} .. ;
I used a variation of above to move all the files from subfolders into the parent.
I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.
eg.
/data/2001/file_1
/data/2002/file_2
/data/2003/file_3
add a comment |
find . -maxdepth 2 -type f -exec mv {} .. ;
I used a variation of above to move all the files from subfolders into the parent.
I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.
eg.
/data/2001/file_1
/data/2002/file_2
/data/2003/file_3
add a comment |
find . -maxdepth 2 -type f -exec mv {} .. ;
I used a variation of above to move all the files from subfolders into the parent.
I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.
eg.
/data/2001/file_1
/data/2002/file_2
/data/2003/file_3
find . -maxdepth 2 -type f -exec mv {} .. ;
I used a variation of above to move all the files from subfolders into the parent.
I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.
eg.
/data/2001/file_1
/data/2002/file_2
/data/2003/file_3
answered Jul 16 '14 at 18:37
Bill Bixby
111
111
add a comment |
add a comment |
Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use
mv * .[A-Za-z0-9]* ..
The .[A-Za-z0-9]*
part is to make sure you don't try to move .
or ..
along, which would fail.
add a comment |
Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use
mv * .[A-Za-z0-9]* ..
The .[A-Za-z0-9]*
part is to make sure you don't try to move .
or ..
along, which would fail.
add a comment |
Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use
mv * .[A-Za-z0-9]* ..
The .[A-Za-z0-9]*
part is to make sure you don't try to move .
or ..
along, which would fail.
Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use
mv * .[A-Za-z0-9]* ..
The .[A-Za-z0-9]*
part is to make sure you don't try to move .
or ..
along, which would fail.
answered Dec 27 '09 at 17:48
ℝaphink
2,80122232
2,80122232
add a comment |
add a comment |
It's simple to move all files and folders to the parent directory in Linux.
Go to that folder and use this command:
mv * /the full path
For example, if your files and folders are as follows:
/home/abcuser/test/1.txt
2.txt
3.jpg
4.php
1folder
2folder
Go to that folder via cd:
cd /home/abcuser/test
mv * /home/abcuser
All your files and folders will move to the abcuser folder (parent directory).
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,/the full path
does not work in Linux, you have to escape spaces with/the full path
.
– slhck
Nov 3 '11 at 11:47
add a comment |
It's simple to move all files and folders to the parent directory in Linux.
Go to that folder and use this command:
mv * /the full path
For example, if your files and folders are as follows:
/home/abcuser/test/1.txt
2.txt
3.jpg
4.php
1folder
2folder
Go to that folder via cd:
cd /home/abcuser/test
mv * /home/abcuser
All your files and folders will move to the abcuser folder (parent directory).
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,/the full path
does not work in Linux, you have to escape spaces with/the full path
.
– slhck
Nov 3 '11 at 11:47
add a comment |
It's simple to move all files and folders to the parent directory in Linux.
Go to that folder and use this command:
mv * /the full path
For example, if your files and folders are as follows:
/home/abcuser/test/1.txt
2.txt
3.jpg
4.php
1folder
2folder
Go to that folder via cd:
cd /home/abcuser/test
mv * /home/abcuser
All your files and folders will move to the abcuser folder (parent directory).
It's simple to move all files and folders to the parent directory in Linux.
Go to that folder and use this command:
mv * /the full path
For example, if your files and folders are as follows:
/home/abcuser/test/1.txt
2.txt
3.jpg
4.php
1folder
2folder
Go to that folder via cd:
cd /home/abcuser/test
mv * /home/abcuser
All your files and folders will move to the abcuser folder (parent directory).
edited Nov 3 '11 at 11:46
3498DB
15.7k114762
15.7k114762
answered Nov 3 '11 at 11:39
Abhishek
1
1
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,/the full path
does not work in Linux, you have to escape spaces with/the full path
.
– slhck
Nov 3 '11 at 11:47
add a comment |
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,/the full path
does not work in Linux, you have to escape spaces with/the full path
.
– slhck
Nov 3 '11 at 11:47
2
2
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,
/the full path
does not work in Linux, you have to escape spaces with /the full path
.– slhck
Nov 3 '11 at 11:47
Thanks @Gareth, was about to the same. Abhishek, please don't post any unrelated links, where's the sense in that? Also, check your formatting please. Additionally,
/the full path
does not work in Linux, you have to escape spaces with /the full path
.– slhck
Nov 3 '11 at 11:47
add a comment |
There is no need to change directories. Just include * at the end of path:
mv /my/folder/child/* /my/folder/
Above only moves non hidden files. To move only hidden files use .*
mv /my/folder/child/.* /my/folder/
Above two can be combined in to one command:
mv /my/folder/child/{.,}* /my/folder/
Also see:
How to move all files including hidden files into parent directory via *
add a comment |
There is no need to change directories. Just include * at the end of path:
mv /my/folder/child/* /my/folder/
Above only moves non hidden files. To move only hidden files use .*
mv /my/folder/child/.* /my/folder/
Above two can be combined in to one command:
mv /my/folder/child/{.,}* /my/folder/
Also see:
How to move all files including hidden files into parent directory via *
add a comment |
There is no need to change directories. Just include * at the end of path:
mv /my/folder/child/* /my/folder/
Above only moves non hidden files. To move only hidden files use .*
mv /my/folder/child/.* /my/folder/
Above two can be combined in to one command:
mv /my/folder/child/{.,}* /my/folder/
Also see:
How to move all files including hidden files into parent directory via *
There is no need to change directories. Just include * at the end of path:
mv /my/folder/child/* /my/folder/
Above only moves non hidden files. To move only hidden files use .*
mv /my/folder/child/.* /my/folder/
Above two can be combined in to one command:
mv /my/folder/child/{.,}* /my/folder/
Also see:
How to move all files including hidden files into parent directory via *
edited May 23 '17 at 12:41
Community♦
1
1
answered Apr 11 '16 at 4:38
ShitalShah
1395
1395
add a comment |
add a comment |
find -type f|while read line; do mv $line ${line##*/}; done
Thanks for contributing an answer. While this might work in simple scenarios, pipingfind
intowhile read
is a bad way to usefind
, and better answers have already been posted.
– Scott
Dec 13 '18 at 16:29
add a comment |
find -type f|while read line; do mv $line ${line##*/}; done
Thanks for contributing an answer. While this might work in simple scenarios, pipingfind
intowhile read
is a bad way to usefind
, and better answers have already been posted.
– Scott
Dec 13 '18 at 16:29
add a comment |
find -type f|while read line; do mv $line ${line##*/}; done
find -type f|while read line; do mv $line ${line##*/}; done
answered Dec 13 '18 at 14:22
Adler
1
1
Thanks for contributing an answer. While this might work in simple scenarios, pipingfind
intowhile read
is a bad way to usefind
, and better answers have already been posted.
– Scott
Dec 13 '18 at 16:29
add a comment |
Thanks for contributing an answer. While this might work in simple scenarios, pipingfind
intowhile read
is a bad way to usefind
, and better answers have already been posted.
– Scott
Dec 13 '18 at 16:29
Thanks for contributing an answer. While this might work in simple scenarios, piping
find
into while read
is a bad way to use find
, and better answers have already been posted.– Scott
Dec 13 '18 at 16:29
Thanks for contributing an answer. While this might work in simple scenarios, piping
find
into while read
is a bad way to use find
, and better answers have already been posted.– Scott
Dec 13 '18 at 16:29
add a comment |
switch to sub directory and execute following command for copy or move files.
ex: a is parent directory and b is sub directory, we want to move/copy all files from b to a (sub directory to parent directory).
cd b
cp * ..
mv * ..
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
add a comment |
switch to sub directory and execute following command for copy or move files.
ex: a is parent directory and b is sub directory, we want to move/copy all files from b to a (sub directory to parent directory).
cd b
cp * ..
mv * ..
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
add a comment |
switch to sub directory and execute following command for copy or move files.
ex: a is parent directory and b is sub directory, we want to move/copy all files from b to a (sub directory to parent directory).
cd b
cp * ..
mv * ..
switch to sub directory and execute following command for copy or move files.
ex: a is parent directory and b is sub directory, we want to move/copy all files from b to a (sub directory to parent directory).
cd b
cp * ..
mv * ..
edited May 20 '16 at 6:58
techraf
3,983111729
3,983111729
answered May 20 '16 at 6:32
M Ikram
1
1
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
add a comment |
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
Welcome to Super User! This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute.
– DavidPostill♦
May 20 '16 at 10:46
add a comment |
Thanks for contributing an answer to Super User!
- 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.
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%2fsuperuser.com%2fquestions%2f88202%2fhow-do-i-move-files-and-directories-to-the-parent-folder-in-linux%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
the question with by far the most complete answer i found: unix.stackexchange.com/q/6393/93768
– DJCrashdummy
Sep 6 '18 at 18:39