~johanvandegriff/unix-shell-programming-revised-edition-programs

unix-shell-programming-revised-edition-programs/myrm -rw-r--r-- 493 bytes
fc214385Johan Vandegriff added other old scripts, some newer ones too 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
if [ "$1" = -m ]
then
  MAXFILES="$2"
  shift 2
else
  MAXFILES="10"
fi

if [ "$#" -eq 0 ]
then
  echo "Usage: `basename $0` [-m maxfiles] files"
  exit 1
fi

if [ "$#" -ge "$MAXFILES" ]
then
  echo -n "More than $MAXFILES files;delete(y/n)?"
  read answer
else
  answer=y
fi

if [ "$answer" != "y" ]
then
  exit
fi

for file
do
  if [ -f "$file" ]
  then
    rm "$file"
  else
    echo "$file does not exist."
    echo "suggestions:"
    eval ls *"$file"* 2> $HOME/errors
  fi
done