[cmd] closest DOS/Windows CMD equivalent of ls -1

 

 

The closest DOS/Windows CMD equivalent of ls -1 (list one entry per line) is:

dir /b

Explanation (precise and unsentimental)

  • ls -1 → forces one file per line

  • dir → Windows directory listing command

  • /b (bare format) → removes headers, footers, sizes, dates, and columns

So:

ls -1        (Unix)
dir /b       (Windows CMD)

Commonly useful variants

List only files (exclude directories):

dir /b /a-d

List only directories:

dir /b /ad

Include hidden files (Unix -a equivalent):

dir /b /a

Recursive (rough equivalent of ls -1R):

dir /b /s

Important clarification (pedantic but necessary)

  • This applies to CMD.EXE (classic DOS-style shell).

  • In PowerShell, ls is an alias for Get-ChildItem, and output is already line-oriented. The exact equivalent there would be:

    Get-ChildItem -Name
    

If you want stricter Unix-like behavior (sorting, inode order, locale rules), CMD cannot replicate it. Use PowerShell or a real Unix environment.

 

posted @ 2026-02-10 04:54  profesor  阅读(3)  评论(0)    收藏  举报