ls
for PowerShell?In PowerShell, the ls
command is used to list the contents of a directory.
This command is equivalent to the dir
command in the Windows Command Prompt.
The ls
command displays the names of the files and subdirectories in the specified directory.
You can use various options with the ls
command to control the information that is displayed and the format of the output. For example, you can use the -l
option to display detailed information about each file and subdirectory, including the owner, the file size, and the last modification time. You can also use the -a
option to include hidden files and directories in the output.
Here is an example of how you might use the ls
command in PowerShell:
PS C:\> ls
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 6/14/2022 1:34 PM Users
-a---- 6/14/2022 1:34 PM 1245 test.txt
PS C:\> ls C:\Users
Directory: C:\Users
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 6/14/2022 1:34 PM John
d----- 6/14/2022 1:34 PM Jane
PS C:\> ls C:\Users\John
Directory: C:\Users\John
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 6/14/2022 1:34 PM 1245 Documents
-a---- 6/14/2022 1:34 PM 2240 Pictures
-a---- 6/14/2022 1:34 PM 632 Music
As you can see, the ls
command can be used to list the contents of the current directory, or you can specify a different directory to list its contents.
The output shows the name and type (file or directory) of each item in the directory, as well as other information depending on the options used.
In PowerShell, the ls
command is used to list the contents of a directory.
Related tutorials curated for you
How to use -filter in Get-ChildItem in PowerShell
What is a Scriptblock in PowerShell?
What is null in PowerShell?
How to order a hashtable in PowerShell
How to use ErrorAction in PowerShell
What is WhatIf in PowerShell?
How to get the host or computer name in PowerShell
Add-Content in PowerShell
How to rename a folder in PowerShell
How to select an object in PowerShell
How to get processes in PowerShell
What are verbs in PowerShell?