LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-07-2006, 04:13 AM   #1
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Rep: Reputation: 30
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.
 
Old 04-07-2006, 04:21 AM   #2
synapse
Member
 
Registered: Jan 2004
Location: On Planet Earth.
Distribution: Slackware 12
Posts: 244

Rep: Reputation: 30
hi

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

cant remember if its capital R or not
 
Old 04-07-2006, 05:13 AM   #3
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Original Poster
Rep: Reputation: 30
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
 
Old 04-07-2006, 05:53 AM   #4
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Code:
mv -R /temp/ /temp1/
That should do it. Why not just rename the temp directory?
Code:
mv temp temp1
 
Old 04-07-2006, 06:41 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
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.

Last edited by jschiwal; 04-07-2006 at 06:43 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot using FTP move command to move files adrianmak Linux - Networking 4 04-21-2009 01:01 PM
Script to Move files jain_rajesh Linux - Newbie 1 10-15-2004 09:53 AM
the best way to move files around..... thegreggwong Linux - Software 5 08-28-2004 06:20 PM
I can't move files at desktop. akihandyman Mandriva 2 08-27-2004 08:38 AM
how do i move hidden files coolinuxguy246 Linux - Newbie 6 06-03-2004 02:33 AM


All times are GMT -5. The time now is 06:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration