Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

equivalent of (dir/b > files.txt) in PowerShell

Tags:

powershell

dir

dir/b > files.txt

I guess it has to be done in PowerShell to preserve unicode signs.

like image 355
Przemysław Banaszek Avatar asked Sep 06 '25 12:09

Przemysław Banaszek


1 Answers

Get-ChildItem | Select-Object -ExpandProperty Name > files.txt

or shorter:

ls | % Name > files.txt

However, you can easily do the same in cmd:

cmd /u /c "dir /b > files.txt"

The /u switch tells cmd to write things redirected into files as Unicode.

like image 53
Joey Avatar answered Sep 09 '25 02:09

Joey