Unix/ls: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 850: | Line 850: | ||
for non-privilegized use: 13951995904 ( 11% ) |
for non-privilegized use: 13951995904 ( 11% ) |
||
All available free space: 20411224064 ( 16% ) |
All available free space: 20411224064 ( 16% ) |
||
</pre> |
|||
It is not visible on the output above, but the digits in the filesize are colored, each 3 digits has different color. |
|||
=={{header|Peri}}== |
|||
The following program lists just the subdirectories, regular files and symlinks, because I do no need the other gizmos generally, but based on these abovementioned file types it is easy to expand with them, if it is necessary. |
|||
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="peri"> |
|||
###sysinclude standard.uh |
|||
###sysinclude args.uh |
|||
###sysinclude io.uh |
|||
###sysinclude str.uh |
|||
###define COLORS |
|||
// delete the COLORS directive above if you do not want colored output! |
|||
#g argc 3 < { "." }{ 2 argv } sto mypath |
|||
@mypath 'd inv istrue { ."The given directory doesn't exist! Exited.\n" end } |
|||
@mypath getdir { ."Cannot load the dir! Aborted.\n" end } sto mydir |
|||
'- 90 *... sto vonal |
|||
'. 60 *... sto points |
|||
@mydir ~d { |
|||
."Directories:\n" |
|||
@mydir ~d {{ #s |
|||
@mydir 'd {{}} octalrights dup print inv mem SPACE |
|||
@mydir 'd {{}} getfilename dup 67 mc print SPACE drop |
|||
@mydir 'd {{}} groupname ': !+ |
|||
@mydir 'd {{}} ownername dup sto temp + dup 10 mc print inv mem @temp inv mem |
|||
@mydir 'd {{}} mtime dup print inv mem |
|||
NL }} |
|||
@points sprintnl |
|||
@mydir ~d { ."Total: " @mydir ~d #g print ." subdirectories.\n" } |
|||
@vonal sprintnl |
|||
} |
|||
@mydir ~r { |
|||
."Regular files:\n" |
|||
@mydir ~r {{ #s |
|||
@mydir 'r {{}} octalrights dup print inv mem SPACE |
|||
@mydir 'r {{}} getfilesize sbr §ifcolored |
|||
@mydir 'r {{}} executable { ." >" }{ ." " } SPACE |
|||
@mydir 'r {{}} getfilename dup 67 mc print SPACE drop |
|||
@mydir 'r {{}} groupname ': !+ |
|||
@mydir 'r {{}} ownername dup sto temp + dup 10 mc print inv mem @temp inv mem |
|||
@mydir 'r {{}} mtime dup print inv mem |
|||
NL }} |
|||
@points sprintnl |
|||
@mydir ~r { ."Total: " @mydir ~r #g print ." regular files. " |
|||
."TotalSize = " @mydir 'r totalsize sbr §ifcolored NL |
|||
} |
|||
@vonal sprintnl |
|||
} |
|||
@mydir ~L { |
|||
."Symlinks:\n" |
|||
@mydir ~L {{ #s |
|||
@mydir 'L {{}} octalrights dup print inv mem SPACE |
|||
@mydir 'L {{}} executable { .">" }{ SPACE } SPACE |
|||
@mydir 'L {{}} getfilename dup 67 mc print SPACE drop |
|||
@mydir 'L {{}} broken { ."--->" }{ ."===>" } SPACE |
|||
@mydir 'L {{}} destination dup 30 mc print drop |
|||
NL }} |
|||
@points sprintnl |
|||
@mydir ~L { ."Total: " @mydir ~L #g print ." symlinks.\n" |
|||
} |
|||
} |
|||
@vonal sprintnl |
|||
."Size, alltogether = " @mydir alltotal sbr §ifcolored NL |
|||
@vonal sprintnl |
|||
@mydir inv mem |
|||
."free spaces: /* Total size of the filesystem is : " @mypath filesystemsize dup sto filsize sbr §ifcolored ." */\n" |
|||
." for non-privilegized use: " @mypath freenonpriv dup sbr §ifcolored |
|||
#g 100 * @filsize / ." ( " print ."% ) " NL |
|||
." All available free space: " @mypath totalfree dup sbr §ifcolored |
|||
#g 100 * @filsize / ." ( " print ."% ) " NL |
|||
@vonal inv mem |
|||
end |
|||
ifcolored: |
|||
###ifdef COLORS |
|||
coloredsize |
|||
###endif |
|||
###ifndef COLORS |
|||
#g !(#s) 21 >| |
|||
###endif |
|||
dup sprint inv mem |
|||
rts |
|||
{ „filsize” } |
|||
{ „mydir” } |
|||
{ „mypath” } |
|||
{ „temp” } |
|||
{ „vonal” } |
|||
{ „points” } |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
Directories: |
|||
0775 arrays vz:vz 2020.11.15 22:44:49 V |
|||
0775 examples vz:vz 2021.02.05 22:58:48 P |
|||
0775 headers vz:vz 2021.01.19 20:34:07 K |
|||
0775 inaneheaders vz:vz 2021.02.21 18:59:46 V |
|||
0775 keyboardlayout_files vz:vz 2021.09.10 21:51:11 P |
|||
0775 libraries vz:vz 2021.09.10 22:20:04 P |
|||
0775 Peri_newlinkerhez root:root 2022.06.19 18:53:37 V |
|||
0775 patterns vz:vz 2021.02.21 17:24:35 V |
|||
0775 perifonts vz:vz 2020.05.09 10:46:19 Szo |
|||
0775 tests vz:vz 2020.11.08 14:44:31 V |
|||
0775 useful vz:vz 2022.01.27 12:16:31 Cs |
|||
............................................................ |
|||
Total: 11 subdirectories. |
|||
------------------------------------------------------------------------------------------ |
|||
Regular files: |
|||
0664 3379 __peri.c vz:vz 2020.11.08 14:35:28 V |
|||
0664 938037 A_Peri_programozasi_nyelv.odt vz:vz 2022.02.16 16:10:56 Sze |
|||
0664 9185 castingoperators.c vz:vz 2020.12.30 20:19:48 Sze |
|||
0664 27148 inanerun.c vz:vz 2021.01.26 12:52:53 K |
|||
0664 14998 jumpingtable.c vz:vz 2021.01.26 12:52:19 K |
|||
0664 15862 keywords.c vz:vz 2021.01.26 12:46:02 K |
|||
0664 3110 libraries.sh vz:vz 2020.12.04 02:46:13 P |
|||
0664 1114 Makefile vz:vz 2020.11.08 14:12:28 V |
|||
0664 257 mybmi.upu vz:vz 2022.01.27 12:15:03 Cs |
|||
0775 10279 > peri vz:vz 2021.09.10 22:20:04 P |
|||
0664 34225 postfixoperators.c vz:vz 2021.01.01 00:16:45 P |
|||
0644 563 preinitpostmortem.c vz:vz 2020.10.25 15:48:55 V |
|||
0664 119 printitself.upu vz:vz 2023.03.21 22:23:24 K |
|||
0664 929840 The_Peri_programming_language.odt vz:vz 2021.09.10 22:23:22 P |
|||
0644 8357 UPU.syntax vz:vz 2021.01.06 18:00:58 Sze |
|||
0664 2199 verify.upu vz:vz 2020.11.29 23:07:42 V |
|||
............................................................ |
|||
Total: 16 regular files. TotalSize = 1998672 |
|||
------------------------------------------------------------------------------------------ |
|||
------------------------------------------------------------------------------------------ |
|||
Size, alltogether = 2043728 |
|||
------------------------------------------------------------------------------------------ |
|||
free spaces: /* Total size of the filesystem is : 126693117952 */ |
|||
for non-privilegized use: 35734585344 ( 28% ) |
|||
All available free space: 42193813504 ( 33% ) |
|||
</pre> |
</pre> |