13

I am trying to move a text file from folder 1 to folder 2 via terminal. I'm doing this for a school project to show what actually happens when you copy paste.

I'm doing

cp/home/rits/desktop/folder1
cp/home/rits/desktop/folder2

and I get

rits@W:~$ cp/home/rits/desktop/folder1
bash: cp/home/rits/desktop/folder1: No such file or directory
tits@W:~$

If you guys can help me out or have any other commands to show how to do basic things like formatting a USB, deleting a file, making a new folder, copying and pasting, moving files via terminal please comment.

2
  • You may find this cheatsheet useful, which lists and gives explanations of some of the most common commands.
    – konapun
    Sep 5, 2013 at 15:00
  • Any command in bash require minimum one space between its name and its arguments. cp is not an exception from the rule. Please see man cp. Sep 5, 2013 at 16:08

3 Answers 3

15

Spot the difference:

cp /home/rits/Desktop/folder1/name_of_textfile /home/rits/Desktop/folder2/
  • a space after cp
  • desktop will be with a D, not a d
  • after that are 2 arguments: filename and destination
  • if you want to copy directories you need -R as an option after cp.
2
  • what if the folder name has a space in it? do i have to use an escape character?
    – BenKoshy
    Jan 28, 2016 at 4:17
  • Easier: use " (cp "/test /a" "/test /b")
    – Rinzwind
    Jan 28, 2016 at 7:34
4

You're using cp the incorrect way, and possibly your desktop folder is called Desktop (but in fact I am on a national language version, so I cannot be sure).

Let's assume that you have these 2 folders:

  1. /home/rits/Desktop/folder1
  2. /home/rits/Desktop/folder2

Also assume that folder1 contains the file: text.txt. Now if you'd like to copy text.txt from folder1 to folder2, you'd go:

cp /home/rits/Desktop/folder1/text.txt /home/rits/Desktop/folder2 

To learn more about commands, either read the manual page of that command by typing man command_name or you can search the internet, and find a vast amount of beginner information like:

2
  • Location for folder1 is /home/rits/Desktop
    – Destro
    Sep 5, 2013 at 15:24
  • Unix paths are case sensitive, so your commands must follow suit. Besides the syntax issues, it is just one other reason when the No such file or directory error message appears.
    – lgarzo
    Sep 5, 2013 at 16:04
0

If you are using MAC book, you are suppose to use following command

cp -R "File/Path/abc.txt" "Destination/Folder/Path"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .