om

om - the most recently modified file in a directory
git clone git://git.larryhynes.net/om
Log | Files | Refs | README | LICENSE

README (1663B)


      1 om - the most recently modified file in a directory
      2 
      3 om identifies the most recently modified regular file in the given
      4 directory and prints the name of that file, possibly preceded by a
      5 path component, on stdout.
      6 
      7 Having moved on from zsh (to ksh) one thing I did miss was zsh's
      8 
      9 	vi *(.om[1])
     10 
     11 to edit the most recent file. Hence om was born. (I did use the
     12 following shell script, which I called 'latest', but om is more
     13 fun.)
     14 
     15 ==================================================================
     16 #!/bin/sh
     17 
     18 if [ -d "$1" ] ; then
     19 	dir=$(cd "$1" || exit ; pwd)
     20 	file=$(ls -1AFt "$1" | sed '/[/*@=%|]$/d' | sed q)
     21 	echo "${dir}"/"${file}"
     22 else
     23 	echo "$1" "is not a directory"
     24 fi
     25 ==================================================================
     26 
     27 EXAMPLES
     28 ========
     29 
     30 	vi "$(om notes)"
     31 
     32 	cp $(om ~/Downloads) ~/src
     33 
     34 	tail -f $(om /var/log)
     35 
     36 	scp `om .` frobzbox:
     37 
     38 	mpv `om dl`
     39 
     40 CAVEATS
     41 =======
     42 
     43 Obviously this is a little bit brain-damaged insofar as one may not
     44 know with absolute certainty which file may be the most recently
     45 modified; that is to say, the file that one thinks will be the most
     46 recently modifed may not always be.
     47 
     48 IMPORTANT DISCLAIMER
     49 ====================
     50 
     51 I have no idea what I'm doing.
     52 
     53 LICENSE
     54 =======
     55 
     56 See LICENSE.
     57 
     58 There is not enough art here to justify rights, but I include a
     59 license to remove any ambiguity and to make it clear that there is
     60 NO WARRANTY OF ANY KIND.
     61 
     62 strlcat.c and strlcpy.c are copyright Todd C. Miller - see those
     63 files for details.
     64 
     65 The use of compat.h was shamelessly lifted from stagit[0] by Hiltjo
     66 Posthuma and Dimitris Papastamos, though I've seen it used in other
     67 projects also.
     68 
     69 [0] https://git.2f30.org/stagit/