LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 07-30-2003, 07:33 AM   #1
DKY
Member
 
Registered: Jul 2003
Posts: 60

Rep: Reputation: 15
how do I move a directory in shell


HELP!!!! I accidentally moved my usr directory into the lost + found directory, now nothing works. I cant even open a terminal.

1. How do I open a terminal?
2. once opened, what commands do I use to move a directory?
 
Old 07-30-2003, 07:54 AM   #2
DKY
Member
 
Registered: Jul 2003
Posts: 60

Original Poster
Rep: Reputation: 15
okay, I figured out how to get a terminal.....now how do I move a directory?
 
Old 07-30-2003, 08:01 AM   #3
Unifex
LQ Newbie
 
Registered: Mar 2003
Posts: 8

Rep: Reputation: 0
mv -r /path/to/mydir /path/to/where/it/should/be/.

In this example "mydir" and it's contents are moved into the directory "be"

The -r tells mv (move) to act recursively. You need this when moving a directory.
 
Old 07-30-2003, 08:02 AM   #4
DKY
Member
 
Registered: Jul 2003
Posts: 60

Original Poster
Rep: Reputation: 15
i just did it without the r....gulp
is that bad?
what does recursive mean?

Last edited by DKY; 07-30-2003 at 08:03 AM.
 
Old 07-30-2003, 08:07 AM   #5
DKY
Member
 
Registered: Jul 2003
Posts: 60

Original Poster
Rep: Reputation: 15
okay, I moved it back to lost+found directory, then went to the lost+found directory, and tried
mv -r usr /
only to have it say
mv: invalid option -- r
Try 'mv --help' for more information.
 
Old 07-30-2003, 10:08 AM   #6
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
recursive means it calls itself over and over. If you dont use -r option than it may not transfer all the files(inside the directory). Normally, you use recursion when removing/deleting the directory but when you are simply moving it, you dont.
just do this:
mv /whatever/file /whatever/desitnation

coo
 
Old 07-30-2003, 04:40 PM   #7
Unifex
LQ Newbie
 
Registered: Mar 2003
Posts: 8

Rep: Reputation: 0
Ah... it's removing directories when the -r is compulsory isn't it?
 
Old 07-30-2003, 05:33 PM   #8
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
yes, thats correct
 
  


Reply



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
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
Move my Home directory... it-s Linux - General 5 07-08-2005 11:34 AM
Move home directory iain.ross Linux - Newbie 6 01-01-2005 04:37 PM
Does anyone know how to move files to a particular directory using shell scripting RowanB Programming 3 11-11-2004 01:46 PM
write permissions for directory - not accidently move/deleted the directory linuxgamer Linux - Newbie 10 12-02-2003 03:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:03 PM.

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
Open Source Consulting | Domain Registration