Linux command
dir 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
List files
dir
List all files
dir -a
List with detailed
dir -l
List with human-readable
dir -lh
List sorted by modification time
dir -t
List sorted by file size
dir -S
List recursively
dir -R
说明
dir lists directory contents, equivalent to ls -C -b. By default, files are listed in columns sorted vertically, and non-graphic characters are displayed as C-style backslash escape sequences. Unlike ls, which changes its output format depending on whether output goes to a terminal or a pipe, dir always produces columnar output with escaped special characters. This makes it more predictable for scripting. The command is part of GNU coreutils and accepts the same options as ls.
参数
- -a, --all
- Include hidden files (starting with .)
- -A, --almost-all
- Like -a but exclude . and ..
- -l
- Long listing format with details
- -h, --human-readable
- Human-readable file sizes (1K, 234M, 2G)
- -t
- Sort by modification time (newest first)
- -S
- Sort by file size (largest first)
- -r, --reverse
- Reverse sort order
- -R, --recursive
- List subdirectories recursively
- -d, --directory
- List directories themselves, not their contents
- -F, --classify
- Append indicator (*/=>@|) to entries
- -i, --inode
- Print inode number of each file
- -s, --size
- Print allocated size of each file in blocks
- --color=_WHEN_
- Colorize output (always, auto, never)
FAQ
What is the dir command used for?
dir lists directory contents, equivalent to ls -C -b. By default, files are listed in columns sorted vertically, and non-graphic characters are displayed as C-style backslash escape sequences. Unlike ls, which changes its output format depending on whether output goes to a terminal or a pipe, dir always produces columnar output with escaped special characters. This makes it more predictable for scripting. The command is part of GNU coreutils and accepts the same options as ls.
How do I run a basic dir example?
Run `dir` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a, --all do in dir?
Include hidden files (starting with .)