Unix/ls: Difference between revisions

1,424 bytes added ,  3 years ago
m
→‎{{header|Phix}}: added pp_IntCh and prettier output version
m (→‎{{header|Phix}}: added pp_IntCh and prettier output version)
Line 1,011:
 
=={{header|Phix}}==
<lang Phix>pp(dir("."),{pp_Nest,1,pp_IntCh,false})</lang>
{{Out}}
<pre>
{{"`."`, "`d"`, 0,20172020,46,311,2113,025,713},
{"`.."`, "`d"`, 0,20172020,46,311,2113,025,713},
{"`.hg"`, "`d"`, 0,20172020,34,274,136,53'5'42,38'&'6},
{"`.hgignore"`, "`a"`, 1533018898,20172020,34,274,13,2957,2137},
{"alice_oz`1KB.txt"zip`, "`a"`, 3369261024,20172019,37,1528,1915,1230,2445},
{"asm"`a.exe`, "d"`a`, 0133889,20172019,48,224,20,33'!'27,39'''21},
{`address.sqlite`, `a`, 12288,2018,7,20,19,44,34},
{`alice_oz.txt`, `a`, 336926,2017,3,15,19,12,24},
{`animation.svg`, `a`, 900,2019,5,25,12,49,14},
...etc
</pre>
===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.
<lang Phi>include builtins\timedate.e
set_timedate_formats({"hh:mmpm Ddd Mmm ddth YYYY"})
object d = dir(".")
if d!=-1 then
printf(1,"%-20s %s %10s %s\n",{"-- name --","attr","size","-- time and date --"})
for i=1 to length(d) do
printf(1,"%-20s %=4s %10s %s\n",{d[i][D_NAME],d[i][D_ATTRIBUTES],file_size_k(d[i][D_SIZE]),format_timedate(d[i][D_YEAR..$])})
end for
end if</lang>
<pre>
-- name -- attr size -- time and date --
. d 0 01:25pm Thu Jun 11th 2020
.. d 0 01:25pm Thu Jun 11th 2020
.hg d 0 06:42am Sat Apr 04th 2020
.hgignore a 18.46KB 01:57pm Sat Apr 04th 2020
1KB.zip a 1KB 03:30pm Sun Jul 28th 2019
a.exe a 130.75KB 08:27pm Sat Aug 24th 2019
address.sqlite a 12KB 07:44pm Fri Jul 20th 2018
alice_oz.txt a 329.03KB 07:12pm Wed Mar 15th 2017
animation.svg a 900 12:49pm Sat May 25th 2019
...etc
</pre>
7,795

edits