-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc7e1
More file actions
42 lines (38 loc) · 711 Bytes
/
c7e1
File metadata and controls
42 lines (38 loc) · 711 Bytes
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
40
41
42
#!/bin/bash
#
# Capitulo 7 exercicio 1
#
if [ $# -lt 1 ] # Recebi pelo menos 1 parametro?
then
echo "Uso: $0 <Nomes dos Arquivos a Deletar>.
Obs. Vale metacaracteres como arqs*"
exit 1
fi
if [ ! "$MAXFILES" ]
then
MAXFILES=10
fi
Qtd=`ls $* 2> /dev/null | wc -l`
if [ "$Qtd" -eq 0 ]
then
echo Nao ha arquivos a serem deletados
exit 2
fi
if [ "$Qtd" -le "$MAXFILES" ]
then
echo "Deveria fazer rm `echo $*`"
exit
fi
if [ "$Qtd" -gt 1 ]
then
echo "Existem $Qtd Arquivos a deletar... \c"
else
echo "So existe 1 arquivo a deletar...\c"
fi
echo " Posso remover? (S/n) \c"
read sn
if [ "$sn" != n ]
then
echo "Deveria fazer rm -f `echo $*`"
exit
fi