From ls --help, dir --help, vdir --help I notice there's no difference at all except for program names (the 'Usage: ' line and a few lines at the bottom). However vdir seems to be some kind of an alias of ls -l, while dir seems like making no difference. Can anyone tell me what are the exact differences among them?
Asked
Active
Viewed 744 times
3
iBug
- 3,428
- 1
- 24
- 57
-
aren't dir & vdir just aliases to variations of ls? – Jeff Schaller Feb 11 '17 at 12:10
-
@JeffSchaller They are 3 separate binary executables in GNU Core Utilities. That's the reason for the title. – iBug Feb 11 '17 at 12:21
-
ok; first google hit made it look like an alias: https://www.gnu.org/software/coreutils/manual/html_node/vdir-invocation.html – Jeff Schaller Feb 11 '17 at 12:28
-
1this doesn't explain why they had to make dir and vdir separate executables instead of hardlinks to ls; a lot of programs work differently by checking the argv0 (eg. ex vs vi); why aren't they doing the same? – Nov 07 '18 at 10:24
1 Answers
6
- From
info dir:diris equivalent tols -C -b - From
info vdir:vdiris equivalent tols -l -b
On an Ubuntu system I have, they appear to be the same binary (they have same exact size), but are not linked to each other, but I assume they could be:
$ ls -li /bin/{ls,dir,vdir}
131116 -rwxr-xr-x 1 root root 126584 Feb 18 2016 /bin/dir
131160 -rwxr-xr-x 1 root root 126584 Feb 18 2016 /bin/ls
131261 -rwxr-xr-x 1 root root 126584 Feb 18 2016 /bin/vdir
On my OpenBSD system, the sizes differ in a way that makes me think that the only thing that differs between them is the name of the utility stored in the binary itself:
$ ls -li /usr/local/bin/{gls,gdir,gvdir}
390089 -rwxr-xr-x 1 root bin 191244 Dec 30 12:31 /usr/local/bin/gdir
390113 -rwxr-xr-x 1 root bin 191243 Dec 30 12:31 /usr/local/bin/gls
390185 -rwxr-xr-x 1 root bin 191245 Dec 30 12:31 /usr/local/bin/gvdir
Kusalananda
- 320,670
- 36
- 633
- 936