-
Notifications
You must be signed in to change notification settings - Fork 87
/
dashes-underscores
executable file
·74 lines (55 loc) · 1.74 KB
/
dashes-underscores
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
#
# Display the given pathname listing with all combinations of dashes and underscores
# i.e. convert each individiual dash to an underscore and vice versa incrementally
# This is to ensure that no archaic paths are missed during directory busting
#
# Written By: Derek Callaway [decal (AT) sdf {D0T} org]
# Last Updated: Sat Apr 21 09:44:44 PDT 2018
# Tested On: Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64 i386
#
if [ ! "$1" ]
then echo "usage: $0 FILE"
echo
echo ' FILE name of file to parse'
echo
echo "ex. $0 webapp-files/misc-common-names.txt"
exit 1
fi
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
echo "y"
return 0
fi
}
echo "n"
return 1
}
for w in `sort -uf "$1"`
do declare -a l=()
[ $(contains "${l[@]}" "$s") != "y" ] && echo $w.${2} && l+=($w.${2})
if [ "`echo $w | grep '-'`" ]
then declare s="$(echo $w | sed 's!-!_!').${2}"
[ $(contains "${l[@]}" "$s") != "y" ] && echo $s && l+=($s)
while [ "`echo $s | grep '-'`" ]
do s="$(echo $s | sed 's!-!_!')"
[ $(contains "${l[@]}" "$s") != "y" ] && echo $s && l+=($s)
done
fi
if [ "`echo $w | grep '_'`" ]
then declare s="$(echo $w | sed 's!_!-!').${2}"
[ $(contains "${l[@]}" "$s") != "y" ] && echo $s && l+=($s)
while [ "`echo $s | grep '_'`" ]
do s="$(echo $s | sed 's!_!-!')"
[ $(contains "${l[@]}" "$s") != "y" ] && echo $s && l+=($s)
done
while [ "`echo $s | grep '-'`" ]
do s="$(echo $s | sed 's!-!_!')"
[ $(contains "${l[@]}" "$s") != "y" ] && echo $s && l+=($s)
done
fi
done
exit 0