I want a to display ALL files (including hidden ones) on a directory in Powershell opened in Windows VsCode. I want the Powershell equivalent of 'ls -a'.
How do I do that?
I've tried:
dir ./d
dir /a
dir ./a
dir /ad
dir \h
...and many variations of these.
Any help?
Thanks
CodePudding user response:
The command in cmd to list all files (and directories) is dir /a
.
PowerShell, on the other hand, has an alias named "dir" (obviously confusing) which actually calls the cmdlet Get-ChildItem
which works different. dir /a
in PowerShell would report an error:
"Get-ChildItem: Cannot find path 'C:\a' because it does not exist."
In order to see all files in PowerShell you would use either of
Get-ChildItem -Force
dir -Force
So which command to use in the end depends on your shell or terminal (with default or chosen shell).
CodePudding user response:
dir /a /b .
is the syntax.
C:\tmp>dir /a /b .
hid
hidsys
nrm
sys
C:\tmp>attrib
A H C:\tmp\hid
A SH C:\tmp\hidsys
A C:\tmp\nrm
A S C:\tmp\sys
CodePudding user response:
Try the following:
dir /s /b /o:gn
/s - displays all files in the specific directory subdirectories.
/b - strips heading information and summary from the output.
/o - sort the files in the list, followed by :gn - g sorts first folders, then files. n puts them in alphabetical order.