Need Unix command to move files to another directory

Spydermag68

Platinum Member
Apr 5, 2002
2,615
98
91
I need the command to move, copy only and not delete the original files.

Assume that I am in the directory I have the files and want to move them to
one directory down....

In dos C:/user to C:user/me


THanks
 

aidanjm

Lifer
Aug 9, 2004
12,411
2
0
if you want to copy the files to the new location, leaving the originals intact in their current position as well, then use the cp (i.e., copy) command. If you actually want to move the files to the new directory, then use the mv (i.e., move) command.

if you're not familiar with the command line, it might be safer to backup up all your files in a tar archive. you can then move the tar file to the desired/ new location and decompress it.

 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
cd /user
cp -R * me

Directory /user/me will automatically be elided by the copy process.
 

Netopia

Diamond Member
Oct 9, 1999
4,793
4
81
Originally posted by: degibson
cd /user
cp -R * me

Directory /user/me will automatically be elided by the copy process.

Ummmm.... wouldn't that end up in some sort of loop? With the -R, you're copying all directories recursively, which would include "me", and then you are adding them to "me", which would make more files that have to be added, since you've got to copy everything in "me", which would make "me" get larger and you'd have to copy it.... etc.

Yeah... I just tested it. It warns you, but then creates some goofy stuff. This is some output from the terminal:

[root@cranium test]# cp -R * me
cp: overwrite `me/me/this.txt'? y
cp: overwrite `me/me/me/this.txt'? y
cp: cannot copy a directory, `me', into itself, `me/me'
cp: overwrite `me/this.txt'? y
[root@cranium test]# ls
me this.txt
[root@cranium test]# ls me
me this.txt
[root@cranium test]# ls me/me
me this.txt
[root@cranium test]# ls me/me/me
me this.txt
[root@cranium test]# ls me/me/me/me
this.txt
[root@cranium test]#
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Hmmm... thats funny. My version of cp does the right thing.
Oh well, do this then:

cd /
cd /user
mv /user/me /otherme
cp -R * /otherme/
mv /otherme /user/me

 
Jun 26, 2007
11,925
2
0
I hate cd'ing into any directory becaue sometimes you get it wrong and when you are using commands like mv or rm that can beome a problem.

So this is how it's done, type man mv, read this carefully, type q to get out of it.

Then type this "mv /home/yourname /home/mynewname"

Of course in your case you'd have to mount the new harddrive somehwere, so it would be somewhat like mv /home/username /mnt/nameofdrive/home/yourname.

If you're not sure, just do a cp -R and delete the orig info when you have checked it out in the new dir.

Welcome to Linux, the OS of the million solutions for your one small problem.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Originally posted by: JohnOfSheffield

Welcome to Linux, the OS of the million solutions for your one small problem.

And the OS that actually has many different versions of basic utilities like cp and mv! :)