#! /bin/sh # Example showing the use of temporary files, and automatic removal # with a trap handler prog=$(basename $0) TMPFILE=$(mktemp /tmp/${prog}.XXXXXX) \ || { echo Cannot make tempfile; exit 1; } trap "rm $TMPFILE; exit" HUP INT QUIT PIPE ALRM TERM echo Your file is $TMPFILE # Here is an example of querying the RPM database for information # about files: rpm -q --qf \ '[%6o{FILEMODES}\t%t{FILEUSERNAME}\t%{FILEGROUPNAME}\t%{FILENAMES}\n]' \ -f "$@" >> $TMPFILE # process TMPFILE, then finally remove it