
NAME
       ph - a fast Slackware Package History tool

SYNOPSIS
       [ROOT=/mnt] ph [options] [-][NUM]

DESCRIPTION
       ph prints a filtered list of the packages installed in a Slackware
       system, using the package description files in /var/log/packages/.

OPTIONS
       NUM is the number of most recently installed packages to list.

       If NUM and globbing are omitted, all packages will be listed.

       If NUM is negative, the first 0-NUM packages will be listed, oldest
       first.

       If ROOT is set, ph can work in a filesystem other than /

   Globbing:
       -g <GLOB>
              List only packages matching <GLOB>.

       -p     List only patches (shorthand for -g "*_slack<release>")

       -s     List only SBo (slackbuilds.org) packages.  (Short for -g "*_SBo")

   Segment Filtering:
       -v Omit printing VERSION.

       -a     Omit printing ARCH.

       -t     Omit printing TAG.

       -n     Only print the NAME (shorthand for -v -a -t -d).

   Date And Time Options:
       -d Omit date and time.

       -f     Use ISO-8601 format for date, with nanosecond accuracy and TZ
              offset.

       -i     Use ls's long-iso format for date - "YYYY-MM-DD HH:MM:SS"

       -u     UNIX epoch time.

       -eu, -gb
              Override LANG and use the EU/GB date format - "DDD DD MM YYYY
              HH:MM:SS".

       -us    Override LANG and use the US date format - "DDD MM DD YYYY
       HH:MM:SS".

       If en_US is detected in LANG, then the US date style is used for the
       default date format, otherwise the European/British style is used.

   Other:
       -r Reverse the output order.

       -h     This.

       --help The other.

       Options  (except  -h  or  --help)  and NUM can be in any order, and used
       multiple times. The last wins.

USAGE
       Package names are divided into segments:

       NAME-VERSION-ARCH-BUILDTAG

       ph, uses ´-´ as a field separator, so here TAG also includes BUILD.

       Not all packages have a TAG - the kernel and original stock  packages
       end  in  a BUILD number, while patches, except kernel updates, end in
       "_slack<release>".

       Globs are always matched first, before any output filtering is done:

       GLOB -> SEGMENT FILTER -> NUM -> DATE FORMAT -> FORWARD/REVERSE LIST

EXAMPLES
   SIMPLE EXAMPLES
       The simplest and probably the most useful operation is just to print a
       list of the most recent installed packages.

       List the last 10 packages that were installed:

              ph 10

       List the last 5 SBo packages that were installed:

              ph -s 5

       List the first 10 packages that were installed:

              ph -10

       Uninstall the last 5 SBo packages:

              removepkg `ph -n -s 5`
         or:
              removepkg $( ph -n -s 5 )

       List all Slackware 14.2 patches installed with dates and times:

              ph -g \*_slack14.2

         or

              ph -p

       Match every package containing ´noarch´ anywhere in the name:

              ph -g "*noarch*"

       Get a date ordered list of names and count of all SBo packages (useful
       for making a sbopkg build queue):

              ph -s -n -r | tee sbo_pkgs.sqf | wc -l

       List all of alienBOB's packages (excluding compat32):

              ph -g \*alien

   MORE COMPLEX EXAMPLES
       List compat32 packages too, making use of grep, sort using the UNIX time
       column, and pipe to less:

              ph -u | grep -e "\(alien\|compat32\) " | sort -nr -k2 | less

       Using a space in front of the closing quote in  grep  avoids
       unintentional  mis‐ matches in the middle of the package name.

       awk can transpose the UNIX epoch times back to a more readable form, and
       reformat into neat columns:

              ph -u | grep -e "\(alien\|compat32\) " | sort -nr -k2 |
              awk '{printf %-50s %s\n , $1, strftime("%c", $NF)}' | less

       List all patches and kernel packages using two instances of ph in a
       subshell:

              ( ph -g kernel-\*; ph -p ) | less

       List last 5 packages not ending in a digit:

              ph -g '*[![:digit:]]' 5

   ROOT
       List the last SBo package installed in a chroot or root partition
       mounted at /mnt/slack:

       ROOT=/mnt/slack ph -s 1

       removepkg also supports ROOT.  Uninstall all packages with a custom
       `daw´ tag:

              ROOT=/mnt/slack removepkg `ph -g "*daw" -n`

         or export it in the shell first:

              ROOT=/mnt/slack
              export ROOT
              removepkg `ph -g "*daw" -n`

   Safety considerations Test without removepkg first to see what packages
   would be removed, or e.g. use ´echo´:

              echo `ph -g "*daw" -n`

       Remember to ´unset ROOT´ before resuming normal operations on the host
       system.

NOTES
       The list order depends on the modification times of the files in
       /var/log/pack‐ ages/. If any files have been modified outside of the
       usual pkgtools applications, then there's a chance that the results
       might not be in order.

       <release> is automatically  determined  from
       [$ROOT]/etc/slackware-version,  but will only work in a proper release,
       i.e. not in -current.

       Old-style  backticks  are  deprecated  in favour of $(...) in some
       shells, but in zsh, they can be used for command substitution, and they
       currently work in bash too.

       ISO-8601  date  format  is very wide, and completely illegible to the
       PFY, but is guaranteed to strike awe and terror into anyone that happens
       to see it whilst walking past the BOFH's VDU. Respect.

TODO
       The voices are telling me to use an alternative to ls.

       And support multiple globs?

       And support regex too?

SEE ALSO
       glob(7), grep(1), awk(1), sort(1), removepkg(8),

AUTHOR
       Dave Woodfall

BUGS
       Maybe. Please send bug reports to dave@tty1.uk
