#!/bin/sh cd $(dirname "$0") tmp=$(mktemp -d) ||Die 1 echo >&2 " tmp $tmp" Die() { e=$? trap - EXIT rm -rf $tmp exit ${1:-$e} }; trap Die HUP EXIT #INT pause() {( echo >&2 -n "Continue? ..." read -sn1 REPLY echo >&2 )} cat >$tmp/txt <<%EOF ABC ... ... ..; ... ... ..; DEF 123 ABC . . . DEF %EOF cc -o $tmp/exe spin.c cd $tmp ||Die 1 2>&1 ( set -v ./exe search ... ;rmdir search ./exe search aA... ;rmdir search ./exe search a. ./exe search ;rmdir search : $'\e[1m---\e[0m' &2 { echo "Removing $tmp... (CTRL-C) to abort." echo " - Press key to continue." }>&2 trap - EXIT read -n1 Die