#!/bin/sh # # clean - script for removing *~ *.o #*# files # prints matching files in current directory and prompts before deletion # # Written by Todd Lisonbee # # if [ -z "$1" ] then echo "Matching Files:" ls *~ 2>/dev/null ls \#*\# 2>/dev/null ls *.o 2>/dev/null echo -n "Do you want to remove all of these files? (y/n) " read answer case $answer in n) echo "No files were removed." ;; y) rm -vf *~ rm -vf \#*\# rm -vf *.o ;; *) echo " *** Invalid Response: $answer -- No files were removed. ***" ;; esac elif [ "$1" = "--help" ] then echo "Usage: clean [OPTION]..." echo 'This script is for removing files that match the patterns *~ *.o #*#' echo "First it prints the matching files in the current directory and prompts \"Do you" echo "want to remove all of these files? (y/n)\". Then it deletes those files or exits." echo " " echo " --help display this help and exit" echo " --version output version information and exit" echo " " elif [ "$1" = "--version" ] then echo "clean - version 0.1" echo "written by Todd Lisonbee" else echo " *** Invalid Option: $@ ***" fi