#!/bin/sh prog=`basename $0` usage() { echo "Usage:" echo " $prog [-u] file" echo "" echo "$prog searches for path-like strings in any file." echo "It is particularly useful for finding filenames in binary files." echo "" echo "Options:" echo " -h Print this message, then exit." echo " -u Do not pass output through 'sort -u'." } set -- `getopt hu ${1+"$@"}` if [ $? != 0 ] ; then usage ; exit 1 ; fi unique=1 for i in ${1+"$@"}; do case "$i" in -h ) usage; exit 0 ;; -u ) unique=0; shift ;; -- ) shift; break ;; esac done if [ $# != 1 ] ; then echo "Usage: $0 [-u] file" ; exit ; fi strings -a "$1" | awk '!/\/.*\// || length > 400 || /[ {}<>()]/ {next} {print}' | case "$unique" in 0 ) cat ;; 1 ) sort -u ;; esac