-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenString.sh
68 lines (58 loc) · 1.26 KB
/
genString.sh
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
#!/bin/bash
# This script is used to insert periods (dots, .) between a string.
# This script is originally intended to generate aliases for Gmail Users (Tutorial Here: https://www.vrnchndk.in/2017/01/20/generate-thousands-of-email-addresses-using-your-own-email-address/)
#
# The script takes 1 input as a simple string
#
# Example:
# ./string_generator.sh random
#
# Original Question asked on SO: https://bit.ly/2RAujRo
# Output:
# ---- one dot ----
# r.andom
# ra.ndom
# ran.dom
# rand.om
# rando.m
# ---- two dots ----
# r.a.ndom
# r.an.dom
# r.and.om
# r.ando.m
# ra.n.dom
# ra.nd.om
# ra.ndo.m
# ran.d.om
# ran.do.m
# rand.o.m
# ---- three dots ----
# r.a.n.dom
# r.a.nd.om
# r.a.ndo.m
# r.an.d.om
# r.an.do.m
# r.and.o.m
# ra.n.d.om
# ra.n.do.m
# ra.nd.o.m
# ran.d.o.m
t=$1
echo '---- one dot ----'
for (( i = 1; i < ${#t}; ++i )); do
echo "${t:0:i}.${t:i}"
done
echo '---- two dots ----'
for (( i = 1; i < (${#t} - 1); ++i )); do
for (( j = i + 1; j < ${#t}; ++j )); do
echo "${t:0:i}.${t:i:j - i}.${t:j}"
done
done
echo '---- three dots ----'
for (( i = 1; i < (${#t} - 1); ++i )); do
for (( j = i + 1; j < ${#t}; ++j )); do
for (( k = j + 1; k < ${#t}; ++k )); do
echo "${t:0:i}.${t:i:j - i}.${t:j:k - j}.${t:k}"
done
done
done