Listing 1
:
#
# scripts | asciis | execs | dirs <path>
# Locate file based on its type in a given path.
# A path is required.
#
if [ $# -ne 1 ]
then
echo "usage: $0 pathname"
exit 0
fi
PROG=`basename $0` # grab the program name sans
# its path
FILE="file $1/* " # how we want the file command
# executed
EOL='s/:.*$//' # define how to clean up output
# from the file command
DTOEOL="sed "$EOL # command to do the clean up
case $PROG in
scripts)
$FILE | grep "commands text" | $DTOEOL ;;
asciis)
$FILE | grep "ascii text" | $DTOEOL ;;
execs)
$FILE | grep "executable" | $DTOEOL ;;
dirs)
$FILE | grep "directory" | $DTOEOL ;;
esac
|