-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdelcontain.sh
More file actions
executable file
·53 lines (45 loc) · 824 Bytes
/
delcontain.sh
File metadata and controls
executable file
·53 lines (45 loc) · 824 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
#!/bin/bash
###
##
# NAME delcontain - delete files containing token
#
# SYNOPSYS delcontain <sdir> <token>
#
# DESCRIPTION Elimina todos los archivos dentro del directorio <sdir> que contienen <token> de forma recursiva
#
# AUTHOR Carolina F. Bravo <carolinafbravo@gmail.com>
# AUTHOR Ramon Antonio Parada <rap@ramonantonio.net>
##
###
if [ $# -lt 2 ]
then
echo "ussage:: delcontain <sdir> <token>"
exit -1
fi
DIR=$1
TOKEN=$2
if [ ! -d $DIR ]
then
echo "$DIR is not a folder"
exit -1
fi
echo "**scanning $DIR"
for line in `ls -1 $DIR`;
do
ABS=$DIR/$line
if [ -d $ABS ]
then
# echo "$ABS DIR"
$0 $ABS $TOKEN
elif [ -f $ABS ]
then
# echo "$ABS FILE"
CONTAINS=`cat $ABS | grep $TOKEN`;
if [[ ! $CONTAINS = "" ]]
then
echo "***deleting $ABS"
rm $ABS
fi
fi
done
echo "**end-scanning $DIR"