Last active
July 19, 2023 20:25
-
-
Save jessykate/4d6417c2ae80715ca65fdac088930de9 to your computer and use it in GitHub Desktop.
a "most recent" command showing file listing of mobi, pdf and epub across sub-directories sorted by time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show the most recent files of type mobi, pdf or epub, sorted with most recent at the bottom. Works on files and subdirectories of the current directory. | |
# Useful references: | |
# find -printf is not POSIX. `-printf` becomes `-print0 | xargs -0 stat -f` | |
# need to convert format specifiers as well. | |
# '%A@ %Ab %Ad %AY %AH:%AM || %P' shows last access time in seconds since the epoch. the month, day, year and time, a "||" separator, then filename. | |
# POSIX's `find` printf arguments: https://man7.org/linux/man-pages/man1/find.1.html | |
# POSIX version (Linux) | |
alias mr="find . -type f \( -iname '*.pdf' -o -iname '*.mobi' -o -iname '*.epub' \) -printf '%A@ %Ab %Ad %AY %AH:%AM || %P \n' | sort -n | cut -f2- -d\" \"" | |
# Less pretty Mac OS version. | |
# `mra` version uses the %a argument to the stat command, showing most recently accessed. | |
# `mrm` version uses the %m argument to the stat command, showing most recently modified. | |
alias mra="find . -type f \( -iname '*.pdf' -o -iname '*.mobi' -o -iname '*.epub' \) -print0 | xargs -0 stat -f '%a %N' | sort -n" | |
alias mrm="find . -type f \( -iname '*.pdf' -o -iname '*.mobi' -o -iname '*.epub' \) -print0 | xargs -0 stat -f '%m %N' | sort -n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment