#! /bin/bash # Last edited on 2024-04-02 15:55:06 by stolfi PROG_NAME=${0##*/} PROG_DESC="a filter that reads the output of {find-all-files-size-date}, excludes junk and archives" PROG_HELP=( "${PROG_NAME} [ -extilde] < {INFILE}.sdf > {OUTFILE}.sdf" ) PROG_INFO=( "\nNAME" "\n ${PROG_NAME} - ${PROG_DESC}." "\n" "\nSYNOPSIS" "\n ${PROG_HELP[@]}" "\n" "\nDESCRIPTION" "\n" "\n Reads a list of files from {stdin}. Discards uninteresting files, writes the rest to stdout." "\n" "\n The input list may be" "\n - a plain list of file names;" "\n - list of links with ' -> ';" "\n - list of size-date-filename as produced by {find_all_files_size_date.sh}" "\n - list of cksum-size-filename as produced by {find_all_files_cksum_size.sh}" "\n - list of cksum-size-date-filename as produced by {find_all_files_cksum_size_date.sh}" "\n" "\n Excludes from the list the known cache files such as from \".cache\" and \".thumbnail\" directories. " "\n" "\n Also excludes the executable binaries listed in {${HOME}/programs/binaries.dir}" "\n" "\n If the \"-extilde\" option is given, also excludes files than end with '~'." "\n" \ "\nSEE ALSO" "\n find_all_files_size_date.sh, find_all_files_cksum_size.sh, find_all_files_cksum_size_date.sh" "\nAUTHOR" "\n Created 2020-09-04 by Jorge Stolfi, Unicamp" "\n Modified 2022-10-16 by J.Stolfi" "\n Modified 2024-03-27 by J.Stolfi to use egrep instead of sed" ) # Parse arguments: extilde=0 while [[ $# -gt 0 ]]; do if [[ "/$1" == "/-exclude-tilde" ]]; then extilde=1; shift; else echo 'unrecognized argument "'"$1"'" ...' 1>&2 echo -e "usage:\n ${PROG_HELP[@]}" 1>&2 ; exit 1 fi done # Prefix for temporary file names tmp="/tmp/$$" echo "excluding junk files ..." 1>&2 xfile="${tmp}_xtrash.grep" echo "preparing ${xfile} ..." 1>&2 rm -f ${xfile} # Files with blanks in name: cat >>${xfile} <>${xfile} <>${xfile} <>${xfile} <>${xfile} <>${xfile} <>${xfile} <>${xfile} <>${xfile} <> ${xfile} fi # Binary executables: cat ${HOME}/programs/binaries.dir \ | sed \ -e 's@^@([ ]|^)(programs/.*|bin|lib)/@g' \ >> ${xfile} echo "see ${xfile}" 1>&2 /usr/bin/egrep -v -f ${xfile} echo "done." 1>&2 # /bin/rm -f ${xfile}