: hunt for a file, brouse in directories, dicks own shell dir0=`pwd`; export dir trap "echo Returning to $dir0" 0 trap "echo; exit 0" 1 2 3 if [ $# -eq 0 ] then dir=$dir0; export dir else while [ $# -gt 0 -a x$directory != xNOT ] do if expr x$1 : x/ >/dev/null then dir=$1 shift else if [ -d $dir/$1 ] then dir=$dir/$1 shift else directory=NOT fi fi done fi # Either $# is zero or $dir/$1 is not a directory while true do if [ $# -gt 0 ] then file=$dir/$1; shift else while [ -d $dir ] do (echo $dir echo " ------------------------------------------------------------" ls -dF $dir/* $dir/.*|sed "s?$dir/? ?g"|grep -n '.'| pr -4 -t ) |more echo " ---------------------------(/ -> directory, *@ -> executable)" echo '( .. to back up, /word to search, !command to do it, CTRL/C to quit)' norf="" # number or file name while [ x"$norf" = x ] ;do /bin/echo 'Choice? \c'; read norf done norf=`expr "$norf" : '^\(.*\)[/*]*$'` case "$norf" in .. ) dir=`expr $dir : '^\(.*\)/[^/]*$'` if [ x$dir = x ]; then dir=/; fi;; CTRL/C| quit|bye|exit) exit 0;; !*) (cd $dir; pwd; eval `expr "$norf" : '!\(.*\)'`);pwd;; /*) fgrep -i `expr x"$norf" : 'x/\(.*\)'` $dir/*|sed 's/[ ][ ]*/ /';; *) if [ -r $dir/"$norf" ] then dir=$dir/"$norf" else dir2=`ls -d $dir/* $dir/.*|sed -n "$norf"p`&&dir=$dir2 fi;; esac done #$file found file=$dir fi ls -l $file; file $file echo "1: view the file using 'more'" echo "2: view the file using 'pg'" echo "3: view the file using 'less'" echo "4: send the file in ASCII" # echo "5: send the file with xmodem" echo "6: make a copy in "`pwd` echo "7: Try to run $file in "`pwd`" using 'quickie'" echo "8: do something else to the file" echo "other: command with % instead of $file" /bin/echo Choice\(1,2,3,4,5,6,7,8\)\?\ '\c';read choice if expr "x$choice" : 'x[12345678]' >/dev/null then choice=`expr $choice : '\(.\).*'` case "x$choice" in x1) echo more $file;more $file;; x2) echo pg $file;pg $file;; x3) echo less $file;less $file;; x4) echo cat $file;cat $file;; x6) echo cp $file .;cp $file .;; x7) echo quickie $file;quickie $file;; x8) echo "Input your command with % in place of $file"; /bin/echo -n $0\:$PS1" ";read command; command=`echo $command|sed "s?%?$file?"`; echo $command; eval $command;; esac else command=`echo $choice|sed "s?%?$file?"`; echo $command eval $command fi dir=`expr $dir : '^\(.*\)/[^/]*$'` done