In the output above, you might notice that there are two special entries – . (current directory) and .. (parent directory). These are called pseudo-files.
If you don’t want to see these special entries in the output, you can use the -A option (short for almost-all).
Displaying File Type Indicators
The -F option, short for “classify”, appends a character after each entry to indicate the type of file. This information can be very useful, especially when you want to identify certain types of files quickly.
As you can see in the screenshot above, the -F option appends a ‘/’ character after each directory. Other indicators are
– for directories
– @ for soft links
– * for executable files
– | for FIFO (named pipes)
There is a similar option called --file-type that does the same except showing * for executable files.
I like to use it for ignoring files of certain types from the display.
As you can see, all the files that start with “temp” and all the files that end with “.txt” are ignored.
Displaying Output in Human Readable Format
The dir command also supports the -h option, short for “human-readable”.
If a file is of size 1024 bytes, it will be displayed as 1K. Similarly, if a file is of size 1048576 bytes, it will be displayed as 1M. This option uses 1000 as the base for file sizes, not 1024.
The dir command also supports the -S option to sort files by size. This can come in handy when you want to see which files are taking up the most space.
dir -S -l
As you can see in the screenshot below, the most space-consuming files are displayed on top.
You might have realized that the dir command is no different than the ls command. ls is more popular and almost every Linux user knows about it. Since dir command doesn’t offer anything special, it doesn’t give reasons to ditch ls command.