You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,20 @@ BASENAME=randtree
50
50
EXTS=(md log json js php jpg png html css)
51
51
```
52
52
53
+
```
54
+
# optional, will increment a count for each EXTS used and
55
+
# show it at the end
56
+
INVEN=true
57
+
# this will use the EXTS array to build an array of counters
58
+
if [ "$INVEN" = true ]; then
59
+
declare -A ext_inven
60
+
for ext in "${EXTS[@]}"
61
+
do
62
+
ext_inven+=(["$ext"]=0)
63
+
done
64
+
fi
65
+
```
66
+
53
67
```
54
68
# "mutable" echoing
55
69
SILENT=true
@@ -68,6 +82,35 @@ This *should* run in most any bash environment. It's been tested under Windows w
68
82
69
83
**NOTE:** Copy the script into a folder where you want the tree to be created. The script will create a *new* folder with the tree inside of it. The new folder will be named with the value of `BASENAME` in the script.
70
84
85
+
### Output Example
86
+
87
+
```
88
+
$ ./randtree.sh
89
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub
90
+
Creating 2 random folders in /scrap/recursmall_sub/recursmall_sub
91
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/JayWb6z
92
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/vFHfuNs
93
+
Creating 2 random folders in /scrap/recursmall_sub/recursmall_sub/JayWb6z
94
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/JayWb6z/1TU6tMN
95
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/JayWb6z/KK4TXlF
96
+
Creating 2 random folders in /scrap/recursmall_sub/recursmall_sub/vFHfuNs
97
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/vFHfuNs/L5eKZ4y
98
+
Creating 5 random files in /scrap/recursmall_sub/recursmall_sub/vFHfuNs/T3ANT2x
99
+
Finshed in /scrap/recursmall_sub/recursmall_sub
100
+
101
+
File Inventory
102
+
[html] = 2
103
+
[jpg] = 3
104
+
[log] = 4
105
+
[txt] = 5
106
+
[js] = 2
107
+
[json] = 6
108
+
[php] = 3
109
+
[css] = 5
110
+
[md] = 2
111
+
[png] = 3
112
+
```
113
+
71
114
## Credits
72
115
73
116
The original source was obtained from https://github.com/eliranbz/bash_create_random_files_and_folders. It provided insight into `mktemp()` and `/dev/urandom`.
0 commit comments