-2

I am learning the commands in PowerShell.

what is the difference between cp and cp -recurse ?

What is the difference between rm and rmdir ? is rm just short for rmdir?

  • Take a look at `Get-Alias` and `Get-Help Get-ChildItem -ShowWindow`. – Bacon Bits Mar 11 '16 at 20:01
  • `cp` see `Get-Help 'Copy-Item' -ShowWindow` and `rm`=`rmdir`, see `Get-Help 'Remove-Item' -ShowWindow` – JosefZ Mar 11 '16 at 20:03
  • This was very helpful, thank you so much. I am still not sure I get the difference between cp and cp -recurse though. This is the info I got: SYNTAX Copy-Item [-Recurse] My understanding of that is just that you CAN add -recurse to copy-item, but not what actually changes by adding it. – Mistress Water Mar 15 '16 at 01:34

1 Answers1

2

In the future you'll want to do more research on your own before asking questions. Otherwise your questions will be rated down.

When you're not sure what a switch does, sometimes it can help to use

get-help [command] -examples

The examples will generally show how an option like -recurse is used with a brief explanation.

But to answer your question, given the directory structure below, using copy-item on Documents will copy the Documents directory. Doc1.txt, Doc2.txt, the MoreDocs directory and everything under it will not be copied. Using the -Recurse option will apply copy-item to Documents and any children or sub-directories found, so you'll copy everything under Documents, including MoreDocs and doc3.txt.

Documents
|---Doc1.txt
|---Doc2.txt
|---MoreDocs
    |---Doc3.txt
RiverHeart
  • 549
  • 6
  • 15