简体   繁体   中英

What is the equivalent of the Windows dir command on macOS?

Does macOS have a command to get list of folders and files in your directory

dir /b/s

Or a command to get file names and save to a text file

 dir /b/s/w *.jpg > "filename.txt"

使用查找(请参阅终端中的查找man findhttps://ss64.com/bash/find.html

find $PWD -type f -name "*.jpg" >"filename.txt" 

macOS is POSIX compliant so it contains the usual command line utilities found in Unix environments.

ls /b/s will list all files in the directory /b/s

ls /b/s/w*.jpg > filename.txt will list all files under /b/s starting with w and ending with .jpg and pipe the output onto a text file called filename.txt

ls /a

can be used check out

https://ss64.com for a full list

ls -l命令将为您提供目录内容的详细信息以及权限,就像dir命令一样。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM