Unix/ls: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added pp_IntCh and prettier output version) |
|||
Line 1,011: | Line 1,011: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<lang Phix>pp(dir("."),{pp_Nest,1})</lang> |
<lang Phix>pp(dir("."),{pp_Nest,1,pp_IntCh,false})</lang> |
||
{{Out}} |
{{Out}} |
||
<pre> |
<pre> |
||
{{ |
{{`.`, `d`, 0,2020,6,11,13,25,13}, |
||
{ |
{`..`, `d`, 0,2020,6,11,13,25,13}, |
||
{ |
{`.hg`, `d`, 0,2020,4,4,6,42,6}, |
||
{ |
{`.hgignore`, `a`, 18898,2020,4,4,13,57,37}, |
||
{ |
{`1KB.zip`, `a`, 1024,2019,7,28,15,30,45}, |
||
{ |
{`a.exe`, `a`, 133889,2019,8,24,20,27,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 |
...etc |
||
</pre> |
</pre> |