Linux - Moving/Copying Files via terminal

In summary, the conversation is discussing the process of moving files and folders from one directory to another. The suggested solution is to use the command `cp mv -vr \Downloads\* .` but the speaker is unsure if it is correct and whether the `-v` argument is necessary. They also mention that the files being copied have the same names but different content. The conversation then shifts to discussing the `mv` command and a tutorial is shared. The final conclusion is that the correct command for moving `dir1` to `dir2` is `mv dir1 dir2`.
  • #1
Arman777
Insights Author
Gold Member
2,168
192
I am trying to move files and folders from one directory to other. Both of the files has multiple subfolders and files.

From the reasearch I have made it seems that the answer should be something like,

`cp mv -vr \Downloads\* .`

But I am not sure this is true or not. I am also not sure about using mv or copy. The files that I am copying have the same file names but the content is different.

Is this command correct ? Do I need '-v` argument ?
 
Technology news on Phys.org
  • #4
Yes sorry it’s that darn spellcheck acting up again. I’m in Yosemite with spotty internet and tried to fix it but lost the signal.
 
Last edited:
  • #5
Thanks for the help..
 
  • Like
Likes berkeman and jedishrfu

1. How do I move a file from one location to another using the terminal?

To move a file from one location to another using the terminal, you can use the "mv" command. The syntax is "mv [file name] [destination]." For example, if you want to move a file named "file1.txt" to a folder named "documents", you would use the command "mv file1.txt documents". This will move the file to the specified destination.

2. Can I move multiple files at once using the terminal?

Yes, you can move multiple files at once using the "mv" command. Simply list all the files you want to move after the destination. For example, if you want to move "file1.txt", "file2.txt", and "file3.txt" to a folder named "documents", the command would be "mv file1.txt file2.txt file3.txt documents".

3. How do I copy a file to a different directory using the terminal?

To copy a file to a different directory using the terminal, you can use the "cp" command. The syntax is "cp [file name] [destination]." For example, if you want to copy a file named "file1.txt" to a folder named "documents", you would use the command "cp file1.txt documents". This will create a copy of the file in the specified destination.

4. Can I copy a directory and its contents using the terminal?

Yes, you can copy a directory and its contents using the "cp" command. Simply add the "-r" option to the command, which stands for "recursive". This will copy the directory and all its subdirectories and files. For example, if you want to copy a folder named "pictures" and all its contents to a folder named "backup", the command would be "cp -r pictures backup".

5. How do I rename a file using the terminal?

To rename a file using the terminal, you can use the "mv" command. The syntax is "mv [current file name] [new file name]." For example, if you want to rename a file named "oldname.txt" to "newname.txt", the command would be "mv oldname.txt newname.txt". This will rename the file to the specified new name.

Similar threads

  • Programming and Computer Science
Replies
20
Views
497
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
16
Views
4K
  • Programming and Computer Science
Replies
1
Views
236
  • Programming and Computer Science
Replies
9
Views
852
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
1
Views
986
  • Programming and Computer Science
Replies
1
Views
469
  • Computing and Technology
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
3K
Back
Top