Unix/ls: Difference between revisions

Content added Content deleted
(Corrected tags)
m (syntax highlighting fixup automation)
Line 37: Line 37:
{{trans|Python}}
{{trans|Python}}


<lang 11l>print(sorted(fs:list_dir(‘.’)).join("\n"))</lang>
<syntaxhighlight lang="11l">print(sorted(fs:list_dir(‘.’)).join("\n"))</syntaxhighlight>


=={{header|8080 Assembly}}==
=={{header|8080 Assembly}}==
Line 44: Line 44:
filenames in sorted order, so it has to do the sorting itself.
filenames in sorted order, so it has to do the sorting itself.


<lang 8080asm>dma: equ 80h
<syntaxhighlight lang="8080asm">dma: equ 80h
puts: equ 9h ; Write string to console
puts: equ 9h ; Write string to console
sfirst: equ 11h ; Find first matching file
sfirst: equ 11h ; Find first matching file
Line 176: Line 176:
fcb: db 0,'???????????' ; Accept any file
fcb: db 0,'???????????' ; Accept any file
ds fcb+36-$ ; Pad the FCB out to 36 bytes
ds fcb+36-$ ; Pad the FCB out to 36 bytes
fnames:</lang>
fnames:</syntaxhighlight>


=={{header|8th}}==
=={{header|8th}}==
<lang forth>
<syntaxhighlight lang="forth">
"*" f:glob
"*" f:glob
' s:cmp a:sort
' s:cmp a:sort
"\n" a:join .
"\n" a:join .
</syntaxhighlight>
</lang>


=={{header|Ada}}==
=={{header|Ada}}==
<lang Ada>with Ada.Text_IO, Ada.Directories, Ada.Containers.Indefinite_Vectors;
<syntaxhighlight lang="ada">with Ada.Text_IO, Ada.Directories, Ada.Containers.Indefinite_Vectors;


procedure Directory_List is
procedure Directory_List is
Line 217: Line 217:
Put_Line(Result.Element(I));
Put_Line(Result.Element(I));
end loop;
end loop;
end Directory_List;</lang>
end Directory_List;</syntaxhighlight>


=={{header|Aime}}==
=={{header|Aime}}==
<lang aime>record r;
<syntaxhighlight lang="aime">record r;
file f;
file f;
text s;
text s;
Line 232: Line 232:
}
}


r.vcall(o_, 0, "\n");</lang>
r.vcall(o_, 0, "\n");</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>print list "."</lang>
<syntaxhighlight lang="rebol">print list "."</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==
{{works with|gawk}} "BEGINFILE" is a gawk-extension
{{works with|gawk}} "BEGINFILE" is a gawk-extension
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f UNIX_LS.AWK * | SORT
# syntax: GAWK -f UNIX_LS.AWK * | SORT
BEGINFILE {
BEGINFILE {
Line 249: Line 249:
exit(0)
exit(0)
}
}
</syntaxhighlight>
</lang>


Sample commands and output under Windows 8:
Sample commands and output under Windows 8:
Line 282: Line 282:


=={{header|BaCon}}==
=={{header|BaCon}}==
<lang freebasic>' Emulate ls
<syntaxhighlight lang="freebasic">' Emulate ls
cnt% = 0
cnt% = 0
files$ = ""
files$ = ""
Line 299: Line 299:
PRINT FLATTEN$(f$)
PRINT FLATTEN$(f$)
NEXT
NEXT
ENDIF</lang>
ENDIF</syntaxhighlight>




=={{header|BASIC256}}==
=={{header|BASIC256}}==
<lang BASIC256>directory$ = dir("m:\foo\bar\") #Specified directory
<syntaxhighlight lang="basic256">directory$ = dir("m:\foo\bar\") #Specified directory
#directory$ = dir(currentdir) #Current directory
#directory$ = dir(currentdir) #Current directory


Line 310: Line 310:
directory$ = dir()
directory$ = dir()
end while
end while
end</lang>
end</syntaxhighlight>




=={{header|C}}==
=={{header|C}}==
C does not have any os-independent way of reading a directory. The following uses readdir and should work on any Unix system.
C does not have any os-independent way of reading a directory. The following uses readdir and should work on any Unix system.
<syntaxhighlight lang="c">
<lang C>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
Line 379: Line 379:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.IO;
Line 406: Line 406:
}
}
}
}
}</lang>
}</syntaxhighlight>


=={{header|C++}}==
=={{header|C++}}==
{{libheader|Boost}}
{{libheader|Boost}}
<lang cpp>
<syntaxhighlight lang="cpp">
#include <iostream>
#include <iostream>
#include <set>
#include <set>
Line 428: Line 428:
std::cout << entry << '\n';
std::cout << entry << '\n';
}
}
</syntaxhighlight>
</lang>


=={{header|Clojure}}==
=={{header|Clojure}}==
<lang clojure>(def files (sort (filter #(= "." (.getParent %)) (file-seq (clojure.java.io/file ".")))))
<syntaxhighlight lang="clojure">(def files (sort (filter #(= "." (.getParent %)) (file-seq (clojure.java.io/file ".")))))


(doseq [n files] (println (.getName n)))</lang>
(doseq [n files] (println (.getName n)))</syntaxhighlight>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
Line 441: Line 441:
The workhorse is `files-list`, which returns a list of filenames. The `ls` function sorts the resulting list and formats it for output.
The workhorse is `files-list`, which returns a list of filenames. The `ls` function sorts the resulting list and formats it for output.


<lang lisp>(defun files-list (&optional (path "."))
<syntaxhighlight lang="lisp">(defun files-list (&optional (path "."))
(let* ((dir (concatenate 'string path "/"))
(let* ((dir (concatenate 'string path "/"))
(abs-path (car (directory dir)))
(abs-path (car (directory dir)))
Line 452: Line 452:


(defun ls (&optional (path "."))
(defun ls (&optional (path "."))
(format t "~{~a~%~}" (sort (files-list path) #'string-lessp)))</lang>
(format t "~{~a~%~}" (sort (files-list path) #'string-lessp)))</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
<lang d>void main() {
<syntaxhighlight lang="d">void main() {
import std.stdio, std.file, std.path, std.array, std.algorithm;
import std.stdio, std.file, std.path, std.array, std.algorithm;


foreach (const string path; dirEntries(getcwd, SpanMode.shallow).array.sort)
foreach (const string path; dirEntries(getcwd, SpanMode.shallow).array.sort)
path.baseName.writeln;
path.baseName.writeln;
}</lang>
}</syntaxhighlight>
=={{header|Delphi}}==
=={{header|Delphi}}==
{{libheader| System.SysUtils}}
{{libheader| System.SysUtils}}
{{libheader| System.IoUtils}}
{{libheader| System.IoUtils}}
<syntaxhighlight lang="delphi">
<lang Delphi>
program LsCommand;
program LsCommand;


Line 503: Line 503:


{$IFNDEF LINUX} readln; {$ENDIF}
{$IFNDEF LINUX} readln; {$ENDIF}
end.</lang>
end.</syntaxhighlight>
{{out}}
{{out}}
<pre>cd foo
<pre>cd foo
Line 518: Line 518:
=={{header|EchoLisp}}==
=={{header|EchoLisp}}==
No directory in EchoLisp, which is run in a browser window. Instead, "stores" (folders) and keys in stores (file names) are located in local storage.
No directory in EchoLisp, which is run in a browser window. Instead, "stores" (folders) and keys in stores (file names) are located in local storage.
<lang lisp>
<syntaxhighlight lang="lisp">
;; ls of stores (kind of folders)
;; ls of stores (kind of folders)
(for-each writeln (list-sort < (local-stores))) →
(for-each writeln (list-sort < (local-stores))) →
Line 535: Line 535:
Glory
Glory
Jonah
Jonah
</syntaxhighlight>
</lang>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>iex(1)> ls = fn dir -> File.ls!(dir) |> Enum.each(&IO.puts &1) end
<syntaxhighlight lang="elixir">iex(1)> ls = fn dir -> File.ls!(dir) |> Enum.each(&IO.puts &1) end
#Function<6.54118792/1 in :erl_eval.expr/5>
#Function<6.54118792/1 in :erl_eval.expr/5>
iex(2)> ls.("foo")
iex(2)> ls.("foo")
Line 548: Line 548:
a
a
b
b
:ok</lang>
:ok</syntaxhighlight>


=={{header|Erlang}}==
=={{header|Erlang}}==
<lang erlang>
<syntaxhighlight lang="erlang">
1> Ls = fun(Dir) ->
1> Ls = fun(Dir) ->
1> {ok, DirContents} = file:list_dir(Dir),
1> {ok, DirContents} = file:list_dir(Dir),
Line 566: Line 566:
b
b
[ok,ok,ok,ok]
[ok,ok,ok,ok]
</syntaxhighlight>
</lang>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
<p>Works with .NET framework 4.</p>
<p>Works with .NET framework 4.</p>
<lang fsharp>let ls = DirectoryInfo(".").EnumerateFileSystemInfos() |> Seq.map (fun i -> i.Name) |> Seq.sort |> Seq.iter (printfn "%s")</lang>
<syntaxhighlight lang="fsharp">let ls = DirectoryInfo(".").EnumerateFileSystemInfos() |> Seq.map (fun i -> i.Name) |> Seq.sort |> Seq.iter (printfn "%s")</syntaxhighlight>
<p>Prior to .NET4 you had to enumerate files and directories separately.</p>
<p>Prior to .NET4 you had to enumerate files and directories separately.</p>
<p>The call to <code>sort</code> is probably redundant, since "sorted by name" seems to be the default in Windows.</p>
<p>The call to <code>sort</code> is probably redundant, since "sorted by name" seems to be the default in Windows.</p>
Line 576: Line 576:
=={{header|Forth}}==
=={{header|Forth}}==
This is much easier without the 'sorted output' requirement:
This is much easier without the 'sorted output' requirement:
<lang forth>256 buffer: filename-buf
<syntaxhighlight lang="forth">256 buffer: filename-buf
: each-filename { xt -- } \ xt-consuming variant
: each-filename { xt -- } \ xt-consuming variant
s" ." open-dir throw { d }
s" ." open-dir throw { d }
Line 587: Line 587:
: ]each-filename ]] repeat drop r> close-dir throw [[ ; immediate compile-only
: ]each-filename ]] repeat drop r> close-dir throw [[ ; immediate compile-only


: ls ( -- ) [: cr type ;] each-filename ;</lang>
: ls ( -- ) [: cr type ;] each-filename ;</syntaxhighlight>


Given that requirement, we must first generate a sorted array of filenames:
Given that requirement, we must first generate a sorted array of filenames:
{{libheader|Forth Foundation Library}}
{{libheader|Forth Foundation Library}}
<lang forth>: save-string ( c-addr u -- a )
<syntaxhighlight lang="forth">: save-string ( c-addr u -- a )
dup 1+ allocate throw dup >r place r> ;
dup 1+ allocate throw dup >r place r> ;


Line 606: Line 606:
: ls ( -- )
: ls ( -- )
[: count cr type ;] each-sorted-filename ;
[: count cr type ;] each-sorted-filename ;
</syntaxhighlight>
</lang>


=={{header|Fortran}}==
=={{header|Fortran}}==
This is possible only for those Fortran compilers that offer some sort of interface with the operating system's file handling routines. Not standard at all! <lang Fortran> PROGRAM LS !Names the files in the current directory.
This is possible only for those Fortran compilers that offer some sort of interface with the operating system's file handling routines. Not standard at all! <syntaxhighlight lang="fortran"> PROGRAM LS !Names the files in the current directory.
USE DFLIB !Mysterious library.
USE DFLIB !Mysterious library.
TYPE(FILE$INFO) INFO !With mysterious content.
TYPE(FILE$INFO) INFO !With mysterious content.
Line 626: Line 626:
END IF !So much for that entry.
END IF !So much for that entry.
IF (MARK.NE.FILE$LAST) GO TO 10 !Lastness is discovered after the last file is fingered.
IF (MARK.NE.FILE$LAST) GO TO 10 !Lastness is discovered after the last file is fingered.
END !If FILE$LAST is not reached, "system resources may be lost." </lang>
END !If FILE$LAST is not reached, "system resources may be lost." </syntaxhighlight>
This relies on the supplied routine GETFILEINFOQQ, which is not at all a standard routine, but it does behave in the same way as is found in many other systems, notably with a file name selection filter, here chosen to be "*" meaning "any file". It supplies successive file names and requires mysterious parameters to keep track of what it is doing. In the installation file C:/Compilers/Furrytran/Compaq Furrytran 6.6a CD/X86/DF/INCLUDE/DFLIB.F90, there is the following segment: <lang Fortran> INTERFACE
This relies on the supplied routine GETFILEINFOQQ, which is not at all a standard routine, but it does behave in the same way as is found in many other systems, notably with a file name selection filter, here chosen to be "*" meaning "any file". It supplies successive file names and requires mysterious parameters to keep track of what it is doing. In the installation file C:/Compilers/Furrytran/Compaq Furrytran 6.6a CD/X86/DF/INCLUDE/DFLIB.F90, there is the following segment: <syntaxhighlight lang="fortran"> INTERFACE
INTEGER*4 FUNCTION GETFILEINFOQQ(FILES, BUFFER,dwHANDLE)
INTEGER*4 FUNCTION GETFILEINFOQQ(FILES, BUFFER,dwHANDLE)
!DEC$ ATTRIBUTES DEFAULT :: GETFILEINFOQQ
!DEC$ ATTRIBUTES DEFAULT :: GETFILEINFOQQ
Line 642: Line 642:
INTEGER*4 dwHANDLE
INTEGER*4 dwHANDLE
END FUNCTION
END FUNCTION
END INTERFACE</lang>
END INTERFACE</syntaxhighlight>
Getting this to work was quite annoying. It turned out that the irritating "files" . and .. are deemed a directory (via the bit in INFO.PERMIT matching that of FILE$DIR = 16) and so can be skipped along with proper subdirectories, but the "PERMIT" value of -1 returned for the FILE$LAST state also matches, though its (non-existent) file name length is given as zero. Thus, if one skips directories filter-style by IF ... GO TO 10, in such a case the end will never be seen. Further, although Fortran syntax allows <code>INFO.PERMIT .AND. FILE$DIR</code> the bit values of logical variables are strange. Instead, what is needed is <code>IAND(INFO.PERMIT,FILE$DIR)</code>
Getting this to work was quite annoying. It turned out that the irritating "files" . and .. are deemed a directory (via the bit in INFO.PERMIT matching that of FILE$DIR = 16) and so can be skipped along with proper subdirectories, but the "PERMIT" value of -1 returned for the FILE$LAST state also matches, though its (non-existent) file name length is given as zero. Thus, if one skips directories filter-style by IF ... GO TO 10, in such a case the end will never be seen. Further, although Fortran syntax allows <code>INFO.PERMIT .AND. FILE$DIR</code> the bit values of logical variables are strange. Instead, what is needed is <code>IAND(INFO.PERMIT,FILE$DIR)</code>


Line 651: Line 651:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>#include "dir.bi"
<syntaxhighlight lang="freebasic">#include "dir.bi"


Sub ls(Byref filespec As String, Byval attrib As Integer)
Sub ls(Byref filespec As String, Byval attrib As Integer)
Line 663: Line 663:
Dim As String directory = "" ' Current directory
Dim As String directory = "" ' Current directory
ls(directory & "*", fbDirectory)
ls(directory & "*", fbDirectory)
Sleep</lang>
Sleep</syntaxhighlight>


=={{header|Frink}}==
=={{header|Frink}}==
<lang frink>for f = sort[files["."], {|a,b| lexicalCompare[a.getName[], b.getName[]]}]
<syntaxhighlight lang="frink">for f = sort[files["."], {|a,b| lexicalCompare[a.getName[], b.getName[]]}]
println[f.getName[]]</lang>
println[f.getName[]]</syntaxhighlight>


=={{header|FunL}}==
=={{header|FunL}}==
<lang funl>import io.File
<syntaxhighlight lang="funl">import io.File


for f <- sort( list(File( "." ).list()).filterNot(s -> s.startsWith(".")) )
for f <- sort( list(File( "." ).list()).filterNot(s -> s.startsWith(".")) )
println( f )</lang>
println( f )</syntaxhighlight>


{{out}}
{{out}}
Line 700: Line 700:
The output is indeed sorted, but not all filetypes alltogether: the sorting algorythm is invoked for the different filetypes separately, because it is the way I like it!
The output is indeed sorted, but not all filetypes alltogether: the sorting algorythm is invoked for the different filetypes separately, because it is the way I like it!


<syntaxhighlight lang="furor">
<lang Furor>
###sysinclude dir.uh
###sysinclude dir.uh
###sysinclude stringextra.uh
###sysinclude stringextra.uh
Line 781: Line 781:
{ „temp” }
{ „temp” }
{ „makestring” #s * dup 10 !+ swap free #g = }
{ „makestring” #s * dup 10 !+ swap free #g = }
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 856: Line 856:


=={{header|Gambas}}==
=={{header|Gambas}}==
<lang gambas>Public Sub Main()
<syntaxhighlight lang="gambas">Public Sub Main()
Dim sDir As String[] = Dir(User.Home &/ "test").Sort()
Dim sDir As String[] = Dir(User.Home &/ "test").Sort()


Print sDir.Join(gb.NewLine)
Print sDir.Join(gb.NewLine)


End</lang>
End</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 872: Line 872:


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 895: Line 895:
fmt.Println(n)
fmt.Println(n)
}
}
}</lang>
}</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Line 901: Line 901:
{{Works with|GHC|7.8.3}}
{{Works with|GHC|7.8.3}}


<lang haskell>import Control.Monad
<syntaxhighlight lang="haskell">import Control.Monad
import Data.List
import Data.List
import System.Directory
import System.Directory
Line 909: Line 909:
main = do
main = do
files <- getDirectoryContents "."
files <- getDirectoryContents "."
mapM_ putStrLn $ sort $ filter (dontStartWith '.') files</lang>
mapM_ putStrLn $ sort $ filter (dontStartWith '.') files</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==
See the [http://www.jsoftware.com/wsvn/base8/trunk/main/main/dir.ijs dir.ijs script] for a full description of the interface for <code>dir</code>:
See the [http://www.jsoftware.com/wsvn/base8/trunk/main/main/dir.ijs dir.ijs script] for a full description of the interface for <code>dir</code>:
<lang J> dir '' NB. includes properties
<syntaxhighlight lang="j"> dir '' NB. includes properties
>1 1 dir '' NB. plain filename as per task</lang>
>1 1 dir '' NB. plain filename as per task</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
{{Works with|Java|11}}
{{Works with|Java|11}}


<lang java>
<syntaxhighlight lang="java">
package rosetta;
package rosetta;


Line 932: Line 932:
}
}
}
}
</syntaxhighlight>
</lang>


The challenge does not state that the files must be sorted in case-insensitive order, and the majority of solutions in other languages do not bother with same.
The challenge does not state that the files must be sorted in case-insensitive order, and the majority of solutions in other languages do not bother with same.
The above can be expanded to sort case-insensitively by mapping Path to String and using the predefined String Comparator:
The above can be expanded to sort case-insensitively by mapping Path to String and using the predefined String Comparator:
<lang java>
<syntaxhighlight lang="java">
Files.list(Path.of("")).map(Path::toString).sorted(String.CASE_INSENSITIVE_ORDER).forEach(System.out::println);
Files.list(Path.of("")).map(Path::toString).sorted(String.CASE_INSENSITIVE_ORDER).forEach(System.out::println);
</syntaxhighlight>
</lang>


=={{header|Javascript}}==
=={{header|Javascript}}==


{{Works with|Node.js|4.3.2+}}
{{Works with|Node.js|4.3.2+}}
<lang javascript>const fs = require('fs');
<syntaxhighlight lang="javascript">const fs = require('fs');
fs.readdir('.', (err, names) => names.sort().map( name => console.log(name) ));</lang>
fs.readdir('.', (err, names) => names.sort().map( name => console.log(name) ));</syntaxhighlight>


=={{header|Jsish}}==
=={{header|Jsish}}==
Line 958: Line 958:
To emulate ''ls'', sorted, one entry per line:
To emulate ''ls'', sorted, one entry per line:


<lang javascript>puts(File.glob().sort().join('\n'));</lang>
<syntaxhighlight lang="javascript">puts(File.glob().sort().join('\n'));</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia># v0.6.0
<syntaxhighlight lang="julia"># v0.6.0


for e in readdir() # Current directory
for e in readdir() # Current directory
Line 969: Line 969:
# Same for...
# Same for...
readdir("~") # Read home directory
readdir("~") # Read home directory
readdir("~/documents")</lang>
readdir("~/documents")</syntaxhighlight>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>// Version 1.2.41
<syntaxhighlight lang="scala">// Version 1.2.41


import java.io.File
import java.io.File
Line 989: Line 989:
fun main(args: Array<String>) {
fun main(args: Array<String>) {
ls(".") // list files in current directory, say
ls(".") // list files in current directory, say
}</lang>
}</syntaxhighlight>


=={{header|Ksh}}==
=={{header|Ksh}}==
<lang ksh>
<syntaxhighlight lang="ksh">
#!/bin/ksh
#!/bin/ksh


Line 1,009: Line 1,009:
print ${obj}
print ${obj}
done
done
</syntaxhighlight>
</lang>


=={{header|LiveCode}}==
=={{header|LiveCode}}==
<lang LiveCode>set the defaultFolder to "/foo"
<syntaxhighlight lang="livecode">set the defaultFolder to "/foo"
put the folders & the files
put the folders & the files
set the defaultFolder to "/foo/bar"
set the defaultFolder to "/foo/bar"
put the folders & the files</lang>
put the folders & the files</syntaxhighlight>


=={{header|Lua}}==
=={{header|Lua}}==
Using LuaFileSystem - available in LuaRocks, ULua, major Linux distro repos, etc, etc.
Using LuaFileSystem - available in LuaRocks, ULua, major Linux distro repos, etc, etc.
<lang Lua>require("lfs")
<syntaxhighlight lang="lua">require("lfs")
for file in lfs.dir(".") do print(file) end</lang>
for file in lfs.dir(".") do print(file) end</syntaxhighlight>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>Column[FileNames[]]</lang>
<syntaxhighlight lang="mathematica">Column[FileNames[]]</syntaxhighlight>


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==
<lang nanoquery>import Nanoquery.IO
<syntaxhighlight lang="nanoquery">import Nanoquery.IO
import sort
import sort


Line 1,033: Line 1,033:
for i in range(0, len(fnames) - 1)
for i in range(0, len(fnames) - 1)
println fnames[i]
println fnames[i]
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>.\nanoquery-2.3_1866
<pre>.\nanoquery-2.3_1866
Line 1,042: Line 1,042:


=={{header|Nim}}==
=={{header|Nim}}==
<lang Nim>from algorithm import sorted
<syntaxhighlight lang="nim">from algorithm import sorted
from os import walkPattern
from os import walkPattern
from sequtils import toSeq
from sequtils import toSeq


for path in toSeq(walkPattern("*")).sorted:
for path in toSeq(walkPattern("*")).sorted:
echo path</lang>
echo path</syntaxhighlight>


=={{header|Objeck}}==
=={{header|Objeck}}==
<lang objeck>
<syntaxhighlight lang="objeck">
class Test {
class Test {
function : Main(args : String[]) ~ Nil {
function : Main(args : String[]) ~ Nil {
Line 1,063: Line 1,063:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|OCaml}}==
=={{header|OCaml}}==


<lang ocaml>let () =
<syntaxhighlight lang="ocaml">let () =
Array.iter print_endline (
Array.iter print_endline (
Sys.readdir Sys.argv.(1) )</lang>
Sys.readdir Sys.argv.(1) )</syntaxhighlight>


{{Output}}
{{Output}}
Line 1,081: Line 1,081:
=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
GP doesn't have this capability so we can either use the shell or PARI. For the latter see [[#C|C]]; for the former:
GP doesn't have this capability so we can either use the shell or PARI. For the latter see [[#C|C]]; for the former:
<lang parigp>system("dir/b/on")</lang>
<syntaxhighlight lang="parigp">system("dir/b/on")</syntaxhighlight>
in DOS/Windows or
in DOS/Windows or
<lang parigp>system("ls")</lang>
<syntaxhighlight lang="parigp">system("ls")</syntaxhighlight>
in *nix.
in *nix.


Line 1,090: Line 1,090:


When tested via Windows XP, the names came out in sorted order (ignoring case) however in earlier systems the files would be presented in entry order. That is, if files a, c, b were saved, they would be named in that order. Then, if file c were deleted and then a file named x were added, they would be named in the order a, x, b. In this case, a scheme for saving an unknown number of names (of unknown length) would be needed so that they could be sorted. Perhaps some linked-list with an insertionsort for each added name...
When tested via Windows XP, the names came out in sorted order (ignoring case) however in earlier systems the files would be presented in entry order. That is, if files a, c, b were saved, they would be named in that order. Then, if file c were deleted and then a file named x were added, they would be named in the order a, x, b. In this case, a scheme for saving an unknown number of names (of unknown length) would be needed so that they could be sorted. Perhaps some linked-list with an insertionsort for each added name...
<syntaxhighlight lang="pascal">
<lang Pascal>
Program ls; {To list the names of all files/directories in the current directory.}
Program ls; {To list the names of all files/directories in the current directory.}
Uses DOS;
Uses DOS;
Line 1,102: Line 1,102:
end;
end;
END.
END.
</syntaxhighlight>
</lang>


=={{header|Perl}}==
=={{header|Perl}}==


<lang perl>opendir my $handle, '.' or die "Couldnt open current directory: $!";
<syntaxhighlight lang="perl">opendir my $handle, '.' or die "Couldnt open current directory: $!";
while (readdir $handle) {
while (readdir $handle) {
print "$_\n";
print "$_\n";
}
}
closedir $handle;</lang>
closedir $handle;</syntaxhighlight>


Alternatively, using <tt>glob</tt>:
Alternatively, using <tt>glob</tt>:
<lang perl>print "$_\n" for glob '*';</lang>
<syntaxhighlight lang="perl">print "$_\n" for glob '*';</syntaxhighlight>


<lang perl>print "$_\n" for glob '* .*'; # If you want to include dot files</lang>
<syntaxhighlight lang="perl">print "$_\n" for glob '* .*'; # If you want to include dot files</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>-->
<!--<syntaxhighlight lang="phix">-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),{</span><span style="color: #004600;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #004600;">pp_IntCh</span><span style="color: #0000FF;">,</span><span style="color: #004600;">false</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),{</span><span style="color: #004600;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #004600;">pp_IntCh</span><span style="color: #0000FF;">,</span><span style="color: #004600;">false</span><span style="color: #0000FF;">})</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{Out}}
{{Out}}
<pre>
<pre>
Line 1,137: Line 1,137:


=== just names ===
=== just names ===
<!--<lang Phix>-->
<!--<syntaxhighlight lang="phix">-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">vslice</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),</span><span style="color: #004600;">D_NAME</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">vslice</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),</span><span style="color: #004600;">D_NAME</span><span style="color: #0000FF;">)</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{Out}}
{{Out}}
<pre>
<pre>
Line 1,148: Line 1,148:
===prettier output===
===prettier output===
Each element of dir() can be indexed with D_NAME, D_ATTRIBUTES, D_SIZE, D_YEAR, D_MONTH, D_DAY, D_HOUR, D_MINUTE, and D_SECOND, and of course you can easily format these things a bit nicer. Of course there is no way to get a proper directory listing in javascript, so for pwa/p2js we'll just create some fake results.
Each element of dir() can be indexed with D_NAME, D_ATTRIBUTES, D_SIZE, D_YEAR, D_MONTH, D_DAY, D_HOUR, D_MINUTE, and D_SECOND, and of course you can easily format these things a bit nicer. Of course there is no way to get a proper directory listing in javascript, so for pwa/p2js we'll just create some fake results.
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">dirf</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">path</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">date_type</span><span style="color: #0000FF;">=</span><span style="color: #004600;">D_MODIFICATION</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">dirf</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">path</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">date_type</span><span style="color: #0000FF;">=</span><span style="color: #004600;">D_MODIFICATION</span><span style="color: #0000FF;">)</span>
Line 1,176: Line 1,176:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 1,205: Line 1,205:
This will output all the filenames in the current directory.
This will output all the filenames in the current directory.


<lang php>
<syntaxhighlight lang="php">
<?php
<?php
foreach(scandir('.') as $fileName){
foreach(scandir('.') as $fileName){
echo $fileName."\n";
echo $fileName."\n";
}
}
</syntaxhighlight>
</lang>


=={{header|Picat}}==
=={{header|Picat}}==
<lang Picat>import os, util.
<syntaxhighlight lang="picat">import os, util.
main =>
main =>
println(ls()),
println(ls()),
Line 1,219: Line 1,219:


ls() = ls(".").
ls() = ls(".").
ls(Path) = [F : F in listdir(Path), F != ".",F != ".."].sort.join('\n').</lang>
ls(Path) = [F : F in listdir(Path), F != ".",F != ".."].sort.join('\n').</syntaxhighlight>




=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(for F (sort (dir))
<syntaxhighlight lang="picolisp">(for F (sort (dir))
(prinl F) )</lang>
(prinl F) )</syntaxhighlight>


=={{header|Pike}}==
=={{header|Pike}}==
<lang Pike>foreach(sort(get_dir()), string file)
<syntaxhighlight lang="pike">foreach(sort(get_dir()), string file)
write(file +"\n");</lang>
write(file +"\n");</syntaxhighlight>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang PowerShell># Prints Name, Length, Mode, and LastWriteTime
<syntaxhighlight lang="powershell"># Prints Name, Length, Mode, and LastWriteTime
Get-ChildItem | Sort-Object Name | Write-Output
Get-ChildItem | Sort-Object Name | Write-Output


# Prints only the name of each file in the directory
# Prints only the name of each file in the directory
Get-ChildItem | Sort-Object Name | ForEach-Object Name | Write-Output</lang>
Get-ChildItem | Sort-Object Name | ForEach-Object Name | Write-Output</syntaxhighlight>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>NewList lslist.s()
<syntaxhighlight lang="purebasic">NewList lslist.s()


If OpenConsole("ls-sim")
If OpenConsole("ls-sim")
Line 1,252: Line 1,252:
EndIf
EndIf
Input()
Input()
EndIf</lang>
EndIf</syntaxhighlight>


=={{header|Python}}==
=={{header|Python}}==
<lang python>>>> import os
<syntaxhighlight lang="python">>>> import os
>>> print('\n'.join(sorted(os.listdir('.'))))
>>> print('\n'.join(sorted(os.listdir('.'))))
DLLs
DLLs
Line 1,270: Line 1,270:
pythonw.exe
pythonw.exe
tcl
tcl
>>> </lang>
>>> </syntaxhighlight>


=={{header|R}}==
=={{header|R}}==
<lang rsplus>
<syntaxhighlight lang="rsplus">
cat(paste(list.files(), collapse = "\n"), "\n")
cat(paste(list.files(), collapse = "\n"), "\n")
cat(paste(list.files("bar"), collapse = "\n"), "\n")
cat(paste(list.files("bar"), collapse = "\n"), "\n")
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,290: Line 1,290:
Ooh... warning... if you run the <code>test</code> module (either with DrRacket with the test module automatically running, or with <code>raco test ls.rkt</code>, then the example directory tree is built but not torn down.
Ooh... warning... if you run the <code>test</code> module (either with DrRacket with the test module automatically running, or with <code>raco test ls.rkt</code>, then the example directory tree is built but not torn down.


<lang racket>#lang racket/base
<syntaxhighlight lang="racket">#lang racket/base


;; Racket's `directory-list' produces a sorted list of files
;; Racket's `directory-list' produces a sorted list of files
Line 1,309: Line 1,309:
(parameterize ([current-directory dir]) (with-output-to-string ls)))
(parameterize ([current-directory dir]) (with-output-to-string ls)))
(test (ls/str "foo") => "bar\n"
(test (ls/str "foo") => "bar\n"
(ls/str "foo/bar") => "1\n2\na\nb\n"))</lang>
(ls/str "foo/bar") => "1\n2\na\nb\n"))</syntaxhighlight>


Both tests pass.
Both tests pass.
Line 1,318: Line 1,318:
There is a <tt>dir</tt> builtin command which returns a list of IO::Path objects. We stringify them all with a hyperoperator before sorting the strings.
There is a <tt>dir</tt> builtin command which returns a list of IO::Path objects. We stringify them all with a hyperoperator before sorting the strings.


<lang perl6>.say for sort ~«dir</lang>
<syntaxhighlight lang="raku" line>.say for sort ~«dir</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
Line 1,326: Line 1,326:
::::* &nbsp; '''b''' &nbsp; is for <u>'''b'''</u>are format (no heading information or summary).
::::* &nbsp; '''b''' &nbsp; is for <u>'''b'''</u>are format (no heading information or summary).
::::* &nbsp; '''o''' &nbsp; is for <u>'''o'''</u>rder, and it orders (sorts alphabetically) by file <u>'''N'''</u>ame.
::::* &nbsp; '''o''' &nbsp; is for <u>'''o'''</u>rder, and it orders (sorts alphabetically) by file <u>'''N'''</u>ame.
<lang rexx>/*REXX program lists contents of current folder (ala mode UNIX's LS). */
<syntaxhighlight lang="rexx">/*REXX program lists contents of current folder (ala mode UNIX's LS). */
'DIR /b /oN' /*use Windows DIR: sorts & lists.*/
'DIR /b /oN' /*use Windows DIR: sorts & lists.*/
/*stick a fork in it, we're done.*/</lang>
/*stick a fork in it, we're done.*/</syntaxhighlight>
{{out|output|text=''':'''}}
{{out|output|text=''':'''}}
<pre>
<pre>
Line 1,338: Line 1,338:


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>
<syntaxhighlight lang="ruby">
Dir.foreach("./"){|n| puts n}
Dir.foreach("./"){|n| puts n}
</syntaxhighlight>
</lang>
This will output all files including hidden ones e.g. '.' and '..'.
This will output all files including hidden ones e.g. '.' and '..'.


=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang Runbasic>files #f, DefaultDir$ + "\*.*" ' RunBasic Default directory.. Can be any directroy
<syntaxhighlight lang="runbasic">files #f, DefaultDir$ + "\*.*" ' RunBasic Default directory.. Can be any directroy
print "rowcount: ";#f ROWCOUNT() ' how many rows in directory
print "rowcount: ";#f ROWCOUNT() ' how many rows in directory
#f DATEFORMAT("mm/dd/yy") 'set format of file date or not
#f DATEFORMAT("mm/dd/yy") 'set format of file date or not
Line 1,356: Line 1,356:
print "time: ";#f TIME$() ' time
print "time: ";#f TIME$() ' time
print "isdir: ";#f ISDIR() ' 1 = is a directory
print "isdir: ";#f ISDIR() ' 1 = is a directory
next</lang>
next</syntaxhighlight>
This will output RunBasics Default Directory.. It can be any directory
This will output RunBasics Default Directory.. It can be any directory
<pre>rowcount: 30
<pre>rowcount: 30
Line 1,374: Line 1,374:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>use std::{env, fmt, fs, process};
<syntaxhighlight lang="rust">use std::{env, fmt, fs, process};
use std::io::{self, Write};
use std::io::{self, Write};
use std::path::Path;
use std::path::Path;
Line 1,397: Line 1,397:
writeln!(&mut io::stderr(), "{}", msg).expect("Could not write to stderr");
writeln!(&mut io::stderr(), "{}", msg).expect("Could not write to stderr");
process::exit(code)
process::exit(code)
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,418: Line 1,418:


=={{header|S-lang}}==
=={{header|S-lang}}==
<lang S-lang>variable d = listdir(getcwd()), p;
<syntaxhighlight lang="s-lang">variable d = listdir(getcwd()), p;
foreach p (array_sort(d))
foreach p (array_sort(d))
() = printf("%s\n", d[p] );</lang>
() = printf("%s\n", d[p] );</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
Line 1,452: Line 1,452:


=={{header|Seed7}}==
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "osfiles.s7i";
include "osfiles.s7i";


Line 1,462: Line 1,462:
writeln(name);
writeln(name);
end for;
end for;
end func;</lang>
end func;</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
Explicit, by opening the current working directory:
Explicit, by opening the current working directory:
<lang ruby>var content = [];
<syntaxhighlight lang="ruby">var content = [];
Dir.cwd.open.each { |file|
Dir.cwd.open.each { |file|
file ~~ < . .. > && next;
file ~~ < . .. > && next;
Line 1,474: Line 1,474:
content.sort.each { |file|
content.sort.each { |file|
say file;
say file;
}</lang>
}</syntaxhighlight>


Implicit, by using the <i>String.glob</i> method:
Implicit, by using the <i>String.glob</i> method:
<lang ruby>'*'.glob.each { |file|
<syntaxhighlight lang="ruby">'*'.glob.each { |file|
say file;
say file;
}</lang>
}</syntaxhighlight>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
cheating solution:
cheating solution:
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>Stdout printCR: ( PipeStream outputFromCommand:'ls' )</lang>
<syntaxhighlight lang="smalltalk">Stdout printCR: ( PipeStream outputFromCommand:'ls' )</syntaxhighlight>
real solution:
real solution:
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>Stdout printCR:('.' asFilename directoryContents sort asStringWith:Character cr)</lang>or:<lang smalltalk>'.' asFilename directoryContents sort do:#printCR</lang>
<syntaxhighlight lang="smalltalk">Stdout printCR:('.' asFilename directoryContents sort asStringWith:Character cr)</syntaxhighlight>or:<syntaxhighlight lang="smalltalk">'.' asFilename directoryContents sort do:#printCR</syntaxhighlight>
full 'ls -l' output:
full 'ls -l' output:
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>dir := '.' asFilename.
<syntaxhighlight lang="smalltalk">dir := '.' asFilename.
dir directoryContentsAsFilenames sort do:[:fn |
dir directoryContentsAsFilenames sort do:[:fn |
|line|
|line|
Line 1,523: Line 1,523:
].
].
line printCR
line printCR
].</lang>
].</syntaxhighlight>
{{out}}
{{out}}
<pre>-rw-r--r-- xxxxx staff 18436 13 Okt 14:16 .DS_Store
<pre>-rw-r--r-- xxxxx staff 18436 13 Okt 14:16 .DS_Store
Line 1,533: Line 1,533:


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang sml>OS.Process.system "ls -a" </lang>
<syntaxhighlight lang="sml">OS.Process.system "ls -a" </syntaxhighlight>
Doing it all by yourself:
Doing it all by yourself:
<lang sml>
<syntaxhighlight lang="sml">
local (* make a sort function *)
local (* make a sort function *)
val rec insert = fn s :string =>fn [] => [s]
val rec insert = fn s :string =>fn [] => [s]
Line 1,551: Line 1,551:


sort result;
sort result;
</syntaxhighlight>
</lang>


=={{header|Stata}}==
=={{header|Stata}}==
Stata has a builtin '''[http://www.stata.com/help.cgi?dir dir]''' command (or equivalently '''ls''').
Stata has a builtin '''[http://www.stata.com/help.cgi?dir dir]''' command (or equivalently '''ls''').


<lang stata>. dir *.dta
<syntaxhighlight lang="stata">. dir *.dta
6.3k 6/12/17 14:26 auto.dta
6.3k 6/12/17 14:26 auto.dta
2.3k 8/10/17 7:34 titanium.dta
2.3k 8/10/17 7:34 titanium.dta
6.0k 8/12/17 9:28 trend.dta</lang>
6.0k 8/12/17 9:28 trend.dta</syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
<lang tcl>puts [join [lsort [glob -nocomplain *]] "\n"]</lang>
<syntaxhighlight lang="tcl">puts [join [lsort [glob -nocomplain *]] "\n"]</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
ls sorts by default, if it doesn't work for you, pipe it's output to sort :
ls sorts by default, if it doesn't work for you, pipe it's output to sort :
<lang bash>
<syntaxhighlight lang="bash">
Aamrun $ ls -1
Aamrun $ ls -1
Applications
Applications
Line 1,592: Line 1,592:
Public
Public
Aamrun $
Aamrun $
</syntaxhighlight>
</lang>
=={{header|Ursa}}==
=={{header|Ursa}}==
<lang ursa>decl file f
<syntaxhighlight lang="ursa">decl file f
decl string<> fnames
decl string<> fnames
set fnames (sort (f.listdir "."))
set fnames (sort (f.listdir "."))
Line 1,600: Line 1,600:
for (decl int i) (< i (size fnames)) (inc i)
for (decl int i) (< i (size fnames)) (inc i)
out fnames<i> endl console
out fnames<i> endl console
end for</lang>
end for</syntaxhighlight>


=={{header|Vlang}}==
=={{header|Vlang}}==
<lang vlang>import os
<syntaxhighlight lang="vlang">import os


fn main() {
fn main() {
contents := os.ls('.')?
contents := os.ls('.')?
println(contents)
println(contents)
}</lang>
}</syntaxhighlight>


=={{header|Wren}}==
=={{header|Wren}}==
<lang ecmascript>import "io" for Directory
<syntaxhighlight lang="ecmascript">import "io" for Directory


var path = "./" // or whatever
var path = "./" // or whatever


// Note that output is automatically sorted using this method.
// Note that output is automatically sorted using this method.
Directory.list(path).each { |f| System.print(f) }</lang>
Directory.list(path).each { |f| System.print(f) }</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
Works on Raspberry Pi.
Works on Raspberry Pi.
<lang XPL0>string 0;
<syntaxhighlight lang="xpl0">string 0;
char S;
char S;
[S:= "ls";
[S:= "ls";
Line 1,626: Line 1,626:
bl system
bl system
}
}
]</lang>
]</syntaxhighlight>


=={{header|zkl}}==
=={{header|zkl}}==
<lang zkl>File.glob("*").sort()</lang>
<syntaxhighlight lang="zkl">File.glob("*").sort()</syntaxhighlight>
Lists all files and directories in the current directory. If you only want a list of files:
Lists all files and directories in the current directory. If you only want a list of files:
<lang zkl>File.glob("*",0x8).sort()</lang>
<syntaxhighlight lang="zkl">File.glob("*",0x8).sort()</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,639: Line 1,639:


The globular method recurses down through the directories. It can send results to objects, functions, methods, threads, etc, etc. To get a sorted list of all the directories under the "Src" directory:
The globular method recurses down through the directories. It can send results to objects, functions, methods, threads, etc, etc. To get a sorted list of all the directories under the "Src" directory:
<lang zkl>File.globular("Src",*,True,0x10,List).sort().concat("\n")</lang>
<syntaxhighlight lang="zkl">File.globular("Src",*,True,0x10,List).sort().concat("\n")</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>