-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherreeme
More file actions
56 lines (48 loc) · 958 Bytes
/
erreeme
File metadata and controls
56 lines (48 loc) · 958 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
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# Salvando Copia de Arquivo Antes de Remove-lo
#
if [ $# -eq 0 ]
then
echo "Erro -> Uso: $0 arq [arq] ... [arq]"
echo " O uso de metacaracteres eh permitido. Ex. erreeme arq*"
exit 1
fi
MeuDir="/tmp/$LOGNAME"
if [ ! -d $MeuDir ]
then
mkdir $MeuDir
fi
if [ ! -w $MeuDir ]
then
echo Impossivel salvar arquivos em $MeuDir. Mude permissao e tente novamente...
exit 2
fi
Erro=0
for Arq
do
if [ ! -f $Arq ]
then
echo $Arq nao existe.
Erro=3
continue
fi
DirOrig=`dirname $Arq`
if [ ! -w $DirOrig ]
then
echo Sem permissao de remover no diretorio de $Arq
Erro=4
continue
fi
if [ "$DirOrig" = "$MeuDir" ]
then
echo $Arq ficara sem copia de seguranca
rm -i $Arq
[ -f $Arq ] || echo $Arq removido
continue
fi
cd $DirOrig
pwd >> $Arq
mv $Arq $MeuDir
echo $Arq removido
done
exit $Erro