bboard hyperpithole gate
 (DIR) Menu
 (DIR) Section <GOPHER>
 (DIR) Forward
 (DIR) Backward
       Thread[.post]: 23.2
       TACKER:  jgw (jgw)
       SUBJECT: .. file sorting
       DATE:    25-Dec-22 18:00:00
       HOST:    faeroes
       
       As long as all the files are of the same Gopher TYPE, ie. "0" for
       plain text, and you don't need to include much else other than the
       file names, then the following will work:
       
        --
       
       #!/bin/sh
       # ./gophermap -  creates listing of files in working directory
       # based on on access times, i.e. the most recent accessed files
       # appear at top.  note: ./gophermap must be executable
       #  => $ chmod 755 ./gophermap
       #
       
       #echo 'v--- sorted by atime --v'  # <= uncomment for testing
       GPHR_DIR="${PWD##*pub}/"
       GPHRTYPE=0  # <= change to match file types
       FMTSTRNG="${GPHRTYPE}%s\t%s%s\tsdf.org\t70\n"
       for FILE in $(/bin/ls -1t *)
       do
         printf "$FMTSTRNG" "$FILE" "$GPHR_DIR" "$FILE"
       done
       
        --
       
       [ SCROLL (F)ORWARD, (B)ACKWARD - (Q)UIT ] FORWARD
        --
       
       Interestingly, if you name this file as, say "my.gophermap", and
       _don't_ also have a main ./gophermap you will get the default
       Gophernicus listing followed by the output of my.gophermap which
       will look something like this:
       
        --
              [/working/gopher/dir/]
       
        (FILE) afile.txt                   2022-Dec-24 12:37    10.3 KB
         (IMG) foobar.jpg                  2022-Dec-24 12:35   120.4 MB
        (FILE) foobar.txt                  2022-Dec-24 12:34    20.3 KB
         (SND) foobar.wav                  2022-Dec-24 12:36    42.0 KB
               v--- sorted by atime --v
        (FILE) foobar.wav
        (FILE) foobar.jpg
        (FILE) foobar.txt
        (FILE) afile.txt
        --
       
       You may get additional default file listing _after_ the output of
       my.gophermap depending on the actual file names.  It's possible to
       have multiple active .gophermap files in a given directory; see
       the reference below for details.
       
       Ref: /usr/local/share/doc/gophernicus/README.Gophermap
       
       
       
       <GOPHER.23.2/11>(109)[ <ENTER> follow thread, (R)EPLY, (F)LAG or (Q)UIT ]