-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_data_gen.sh
53 lines (43 loc) · 1.46 KB
/
test_data_gen.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
#!/bin/bash
# Function to generate a random string with a fixed seed
generate_random_string() {
local length=$1
local seed=$2
echo "$seed" | md5 | head -c $length
}
# Function to create random files and directories with a fixed seed
create_random_files_and_dirs() {
local base_dir=$1
local num_dirs=$2
local num_files=$3
local depth=$4
local seed=$5
if [ $depth -le 0 ]; then
return
fi
for ((i = 0; i < num_dirs; i++)); do
local dir_name=$(generate_random_string 8 "$seed-$i")
local dir_path="$base_dir/$dir_name"
mkdir -p "$dir_path"
echo "Created directory: $dir_path"
# Recursively create files and directories in the new directory
create_random_files_and_dirs "$dir_path" $((num_dirs / 2)) $((num_files / 2)) $((depth - 1)) "$seed-$i"
done
for ((i = 0; i < num_files; i++)); do
local file_name=$(generate_random_string 8 "$seed-$i")
local file_path="$base_dir/$file_name.txt"
head -c 1048576 </dev/urandom >"$file_path" # Increase file size to 1MB
echo "Created file: $file_path"
done
}
# Main script
BASE_DIR="./test_data"
NUM_DIRS=50
NUM_FILES=10000
DEPTH=10
SEED="fixed_seed"
# Create base directory if it doesn't exist
mkdir -p "$BASE_DIR"
# Generate random files and directories with a fixed seed
create_random_files_and_dirs "$BASE_DIR" $NUM_DIRS $NUM_FILES $DEPTH "$SEED"
echo "Random file and directory generation complete."