LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to move files from a subdirectory to another? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-move-files-from-a-subdirectory-to-another-432600/)

Akhran 04-07-2006 03:13 AM

How to move files from a subdirectory to another?
 
File structure:

/temp/
/temp/testdir1/
/temp/testdir2/

/temp1/

I'm trying to move files in /temp/testdir1 and /temp/testdir2 to /temp1. When I use the command 'mv /temp/*.* /temp1', only the files in /temp/ are moved, but the subdirectories testdir1 and testdir2 are not moved to /temp1.

Any help would be deeply appreciated!

Thanks.

synapse 04-07-2006 03:21 AM

hi

try mv -R /temp/*.* /temp1
or mv -r /temp/*.* /temp1

cant remember if its capital R or not

Akhran 04-07-2006 04:13 AM

I get invalid option for both -r and -R.

Quote:

Originally Posted by synapse
hi

try mv -R /temp/*.* /temp1
or mv -r /temp/*.* /temp1

cant remember if its capital R or not


scuzzman 04-07-2006 04:53 AM

Code:

mv -R /temp/ /temp1/
That should do it. Why not just rename the temp directory?
Code:

mv temp temp1

jschiwal 04-07-2006 05:41 AM

From your description, it sounds like you want to execute two separate commands:
mv /temp/testdir1/* /temp1/
mv /temp/testdir2/* /temp1/

Although, this could be combined as "mv /temp/testdir1/* /temp/testdir2/* /temp1/"

Look through the man page for "mv". There is no -r or -R option. You are thinking of the "cp" command.

If you want to move just files, and not subdirectories, then you will want to use the "find" command.

find /temp/testdir1 -maxdepth 1 -type f -exec mv '{}' /temp1/ \;
find /temp/testdir2 -maxdepth 1 -type f -exec mv '{}' /temp1/ \;

If there are only the two subdirectories testdir1 and testdir2, then the single command
find /temp/ -maxdepth 2 -type f -exec mv '{}' /temp1/ \;
would work.


All times are GMT -5. The time now is 01:29 AM.