Robert Elder Software Inc.
  • Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'vdir' Command In Linux

2023-06-13 - By Robert Elder

     I use the 'vdir' command:

vdir

     to do exactly the same thing as this 'ls' command:

/usr/bin/ls -l -b

     And that's pretty much all there is to this command.

The '-l' Flag

     The regular 'ls' command produces output like this:

ls
enough.c  gun.c       gzjoin.c  gzlog.h   README.examples  zpipe.c  zran.h
fitblk.c  gzappend.c  gzlog.c   gznorm.c  zlib_how.html    zran.c

     And the '-l' flag causes entries to be listed in the long format:

ls -l
total 248
-rw-r--r-- 1 robert robert 24856 Aug 23  2022 enough.c
-rw-r--r-- 1 robert robert  8596 Aug 23  2022 fitblk.c
-rw-r--r-- 1 robert robert 25942 Aug 23  2022 gun.c
-rw-r--r-- 1 robert robert 16978 Aug 23  2022 gzappend.c
-rw-r--r-- 1 robert robert 14132 Aug 14  2012 gzjoin.c
-rw-r--r-- 1 robert robert 41541 May 26  2019 gzlog.c
-rw-r--r-- 1 robert robert  4558 Aug 23  2022 gzlog.h
-rw-r--r-- 1 robert robert 22182 Oct  7  2018 gznorm.c
-rw-r--r-- 1 robert robert  1970 Oct 14  2018 README.examples
-rw-r--r-- 1 robert robert 29824 Dec 11  2005 zlib_how.html
-rw-r--r-- 1 robert robert  6323 Dec 11  2005 zpipe.c
-rw-r--r-- 1 robert robert 18158 Aug 23  2022 zran.c
-rw-r--r-- 1 robert robert  2131 Oct 14  2018 zran.h

The '-b' Flag

     The '-b' flag enables C style escaping for non-graphical characters.  For example, if I create this file whos name contains non-graphical characters:

touch $(echo -e "escape-\x1B-escape.txt")

     the plain 'ls' command shows the file name like this:

ls escape-^[-escape.txt
'escape-'$'\033''-escape.txt'

     and the 'ls -b' command shows the file name like this:

ls -b escape-^[-escape.txt
escape-\033-escape.txt

Same Source & Documentation

     If you do a comparison between the man pages for the 'ls' command and the 'vdir' command, you'll see that the only difference is that the word 'ls' has been replaced by the word 'vdir':

vdir ls man Page Comparison
vim -d <(man ls) <(man vdir)

     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 'vdir' command as well as the 'dir' command are simply thin wrappers around the 'ls' command that are enabled using a global variable:

/*
   ...
   If ls_mode is LS_LONG_FORMAT,
   the long format is the default regardless of the
   type of output device.
   This is for the 'vdir' program.
   ...
*/

     And that's why the 'vdir' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Intro To 'stty' Command In Linux
Published 2023-10-04
Terminal Block Mining Simulation Game
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
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
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List
Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
SocialSocialSocialSocialSocialSocialSocial
Privacy Policy      Store Policies      Terms of Use