The dir
command¶
The dir
command lists the contents of a directory(the current directory by default). It differs from ls command in the format of listing the content. By default, the dir command lists the files and folders in columns, sorted vertically and special characters are represented by backslash escape sequences.
Syntax:¶
[linux] dir [OPTIONS] [FILE]
Examples:¶
- To list files in the current directory:
[linux] dir
- To list even the hidden files in the current directory:
[linux] dir -a
- To list the content with detailed information for each entry
[linux] dir -l
Additional Flags and their Functionalities:¶
Short Flag | Long Flag | Description |
---|---|---|
-a | --all | It displays all the hidden files(starting with . ) along with two files denoted by . and .. |
-A | --almost-all | It is similar to -a option except that it does not display files that signals the current directory and previous directory. |
-l | Display detailed information for each entry | |
-s | --size | Print the allocated size of each file, in blocks File |
-h | --human-readable | Used with with -l and -s, to print sizes like in human readable format like 1K, 2M and so on |
-F | Classifies entries into their type based on appended symbol (/ , * , @ , % , = ) | |
-v | --verbose | Print source and destination files |
--group-directories-first | To group directories before files | |
-R | --recursive | To List subdirectories recursively. |
-S | sort by file size, display largest first |
Last update: 2022-05-12