#!/bin/sh # Copyright (C) 2000 Berlin h-peter recktenwald # simplified # substituting - re below: # [ "`basename ${ii} .gz`.gz" == "${ii}" ] # or [ "${ii##*.}" == "gz" ] # binary from asmutils 0.09+ (http://linuxassembly.org) unset d i ii n r v # [ "${0##*/})" = "fdv" ] && v=1 || v="" [ "${*}" == "h" -o -z "${*}" ] && { echo -e "simplified 'find':\tfd [[/]path] filename [\"textsegment\"] \t is regular expression as for 'egrep', \twhich most certainly must be quoted to correctly evaluate; \tfile to search may be -ed (with .gz affix). \tret /path/name (absolute), or empty string. \trequires 'extname' (from asmutils) somewhere in PATH. (re ${0} for a substitute)";exit 1 } # b='-follow';#debian , ${b} sometimes required, sometimes not... r="$(pwd -P)" pushd $(pwd) &> /dev/null [ -n "${2}" ] && test -d "${1}" && { cd "${1}";shift;r="$(pwd -P)"; } [ -n "${2}" ] && { find "${r}" ${b} -xtype f -depth -iname "${1}" -print 2>/dev/null|while read i do [ -d "${i}" ] && continue [ "${i}" != "${i/\/proc\//}" ]||{ ii="${i##*/}" [ -z "${ii}" ] && continue d="${i%/*}" [ -n "${d}" ] || d="./" [ "${ii##*.}" == "gz" ] && { gunzip -c ${d}/${ii} >/tmp/${ii}${$};wait;ii="/tmp/${ii}${$}"; }||{ ii="${d}/${ii}";d=""; } egrep -il "${2}" ${ii} >/dev/null 2>&1&&echo ${i} [ -z "${d}" ] || rm -f ${ii} } done 2>/dev/null i=" ${ii} done" }|| i=$(find "${r}" ${b} -depth -iname "${1}" -print 2>/dev/null) [ -n "${i}" ]&& { for r in "${i}";do [ -z "${i}" ] || echo "${i}";done; }|| { [ -n "${v}" ] && echo -e "no file(s) \"${1}\" found in \"${r}\""; }|| exit 1 popd &> /dev/null