Home > Mobile >  What is the actual purpose of the command "dir -R" in PowerShell?
What is the actual purpose of the command "dir -R" in PowerShell?

Time:11-23

Good Evening,

New programmer here and the first thing I was told to begin studying was PowerShell and the Command prompt prior to my journey on Python.

While doing some exercises listed in the book I came across the command dir -R, this command listed all files in the folder(s), which made it easier then going to each folder and typing ls.

What is the actual description of this command and why does it list all the files, not just in a straight line but it goes line by line.

I like to understand the basic functions of what I'm learning so I have full understanding, while doing a Google search I could not find a answer.

Thank you in advance.

CodePudding user response:

In Powershell dir is an alias name for Get-ChildItem Cmdlet. You can confirm it by Get-Alias dir

> Get-Alias dir

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           dir -> Get-ChildItem

So dir -R is equivalent to Get-ChildItem -Recurse which will gets the items in the specified locations and in all child items of the locations.

CodePudding user response:

The dir command is just an alias for Get-ChildItem.

So dir -R would be equivalent to Get-ChildItem -Recurse.

  • Related