15

How Could i copy or cut a file from a directory to another directory?

I mean in command line!

1
  • 2
    You might also want to look at their man pages Copy and Move
    – atenz
    Jul 16, 2012 at 11:15

3 Answers 3

15

Simple: type in terminal

For copy

cp /PATH1/file [file2 file3 ...] /PATH2/[newfilename or noting to use the same name]

and for more info about cp use man cp


For cut(move and rename)

mv /PATH1/file /PATH2/[newfilename or noting to use the same name]

and for more info about mv use man mv

4
  • thank you! but i have to use just mv and cp? copy and move didn`t work? Jul 16, 2012 at 11:13
  • 1
    you @MiladSobhkhiz can use copy and move too, depending in what os you are using....
    – hingev
    Jul 16, 2012 at 11:21
  • 1
    He said, he is using Ubuntu
    – Anwar
    Jul 16, 2012 at 11:29
  • 1
    The correct commands are mv and cp. You can create alias if you want and make copy respond to cp for example.
    – LnxSlck
    Jul 16, 2012 at 11:35
6

Hi here we go with a practical example:

1. Copy 

    raja@badfox:~/Folder$ mkdir copy
    raja@badfox:~/Folder$ mkdir move
    raja@badfox:~/Folder$ touch file1 file2 file3 file4
    raja@badfox:~/Folder$ cp file1 copy
    raja@badfox:~/Folder$ ls copy
    file1

2. Move


    raja@badfox:~/Folder$ ls
    copy  file1  file2  file3  file4  move
    raja@badfox:~/Folder$ mv file2 move
    raja@badfox:~/Folder$ ls move
    file2
    raja@badfox:~/Folder$ ls
    copy  file1  file3  file4  move


3. Rename

    raja@badfox:~/Folder$ mv file3 file2
    raja@badfox:~/Folder$ ls
    copy  file1  file2  file4  move
    raja@badfox:~/Folder$ 
1

Here is my view of it. You want to move file1 from dir1 to file2 in dir2, So here is how: mv /PATH/TO/FILE1/ /PATH/TO/FILE2/ practical example: ~/Documents$ ls text.txt
cd .. cd Desktop ls
cd .. mv ~/Documents/text.txt/ ~/Desktop/text.txt cd Desktop ls
text.txt

Hope it helps and isn't too complicated :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.