Intro To 'dir' Command In Linux
2023-06-02 - By Robert Elder
I use the 'dir' command to do exactly the same thing as this 'ls' command:
/usr/bin/ls -C -b
and that's pretty much all there is to this command.
-C And '-b' Flags
The '-C' flag causes entries to be listed by columns, and the '-b' flag enables C style escaping for non-graphical characters:
touch $(echo -e "escape-\x1B-escape.txt")
ls escape-^[-escape.txt
'escape-'$'\033''-escape.txt'
ls -b escape-^[-escape.txt
escape-\033-escape.txt
ls escape-^[-escape.txt | xxd
00000000: 6573 6361 7065 2d1b 2d65 7363 6170 652e escape-.-escape.
00000010: 7478 740a txt.
Same Source & Documentation
If you do a comparison between the man pages for the 'ls' command and the 'dir' command, you'll see that the only difference is that the word 'ls' has been replaced by the word 'dir':
vim -d <(man ls) <(man dir)
You can further verify the connection between these two commands by reviewing the source code for the 'ls' command, where a comment shows that the 'dir' command as well as the 'vdir' command are simply thin wrappers around the 'ls' command:
...
/* If ls_mode is LS_MULTI_COL,
the multi-column format is the default regardless
of the type of output device.
This is for the 'dir' program.
...
And that's why the 'dir' command is my favourite Linux command.
Intro To 'stty' Command In Linux
Published 2023-10-04 |
$1.00 CAD |
Intro To 'nproc' Command In Linux
Published 2023-07-15 |
Intro To 'comm' Command In Linux
Published 2023-09-06 |
How To Force The 'true' Command To Return 'false'
Published 2023-07-09 |
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21 |
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01 |
Intro To 'chroot' Command In Linux
Published 2023-06-23 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|