diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-05-06 19:08:45 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-05-06 19:08:45 +0800 |
| commit | eddb76ad8c6e850c7e24f97ff27a185d48b104ee (patch) | |
| tree | 3ffe8f996aea9cf68f3b5df0c6183cbade2cec74 | |
| parent | 4623c35ed189c8ed6b9ced043a9df4e7f9558ba0 (diff) | |
| download | site-search-bm-eddb76ad8c6e850c7e24f97ff27a185d48b104ee.tar.gz | |
Ensure 16 KB content in test files.
| -rwxr-xr-x | seed.sh | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#!/bin/ksh + +# Accept directory count as an argument, default to 500 +TOTAL=${1:-500} + +# Define the base path relative to the script location +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +BASE_DIR="$SCRIPT_DIR/_site/log" + +# Target size: 16000 bytes is ~15.6 KB +CONTENT_SIZE=16000 + +# Ensure the target directory exists +mkdir -p "$BASE_DIR" + +for i in $(seq 1 $TOTAL); do + DIR="$BASE_DIR/site_$i" + mkdir -p "$DIR" + + # Start the file structure + echo "<html><head><title>Site $i</title></head><body><main><p>" > "$DIR/index.html" + + # Generate random text using dd for byte-level precision + # We read 32KB of raw data to account for characters filtered out by tr, + # then use dd again to trim the result to exactly CONTENT_SIZE bytes. + dd if=/dev/urandom bs=32768 count=1 2>/dev/null | tr -dc 'a-zA-Z0-9 ' | dd bs=1 count=$CONTENT_SIZE 2>/dev/null >> "$DIR/index.html" + + # Append keyword and close tags + echo " Searchable content here for keyword_$i. </p></main></body></html>" >> "$DIR/index.html" + + # Print progress every 100 files + if [ $((i % 100)) -eq 0 ]; then + echo "Created $i files..." + fi +done + +echo "Done! $TOTAL directories created in $BASE_DIR." |
