Everyone is likely familiar with Stata's ls command, which lists the files in the current directory, just like the Unix command ls. In the help file for Stata's ls there is only one option with ls, wide. However, I've found that Stata's ls also accepts the very same Unix-style command flags that one can use with ls in their terminal:
However they do not work in conjunction with filename search patterns:
and I've never seen another Stata function style its options this way. What is behind this? Wouldn't this implementation require a very different type of syntax parsing than for comma-style options? I do notice that it is a Stata built-in, so perhaps it isn't coded in ado or even mata. But it also doesn't seem to be a direct pass-thru to my shell's ls because it can't handle (for instance) zsh glob qualifiers. For example, if I use the zsh glob qualifier to show the last 5 files based on modification date:
but if I use my operating system's ls through shell with the same syntax:
it works as expected just like in my terminal. Does anyone have an explanation or similar experience? My question is perhaps not one of critical importance; it just comes from a very curious party.
Code:
. ls -t // sort by modification time . ls -S // sort by file size . ls -1 // force output to one entry per line . ls -a // do not ignore entries starting with . (invisibles)
Code:
. ls -t *.ado invalid '*' r(198); . ls *.dta -S invalid '-' r(198); . ls -t raw_data/ invalid 'raw_data' r(198); . ls raw_data/ total 0 -rw-r--r-- 1 adunlop staff 107928278317 Apr 26 22:17 datadump.csv
Code:
. ls *(D.om[1,5])
invalid '('
r(198);
Code:
. shell ls *.ado(D.om[1,5]) some_prog.ado some_other_prog.ado another_prog.ado one_more_program.ado an_additional_program.ado
Comment