Code Generation
Code Generation #4

Write a Bash script that watches a directory and prints a summary whenever a new file appears. The summary should include: filename, file size in human-readable form, file type (from the `file` command), and a SHA-256 hash. Handle the case where the directory doesn't exist yet.

14 models responded

GPT-5.4OpenAI
high8.5

Judge: A bash script that waits for the directory to exist, watches via inotifywait, and prints filename, human-readable size, file type, and SHA-256 hash, meeting all hard constraints. Quoting is careful (-- and quoted vars) and it handles vanished files and special chars; it uses 'set -u' rather than full 'set -euo pipefail' and relies on Linux-only tools (inotifywait, stat -c, numfmt), which is reasonable but limits portability.

#!/usr/bin/env bash set -u Usage: ./watch_new_files.sh /path/to/watch WATCH_DIR="${1:-}" if [[ -z "$WATCH_DIR" ]]; then echo "Usage: $0 /path/to/watch" exit 1 fi if ! command -v inotifywait >/d...
openai/gpt-5.4 · 2026-06-11
Claude FableAnthropic
high8.5

Judge: Syntax-checked clean, and the missing-directory handling was verified live (it waits, detects the directory appearing, and starts watching). All four summary fields are produced (du -h size, file -b type, sha256sum), with an inotify mode plus a polling fallback that pre-seeds existing files and uses null-delimited find for special filenames. Dings: du reports block-rounded disk usage rather than exact file size, the associative array silently requires bash 4+ (it breaks on macOS's stock bash 3.2, a portability gap the otherwise-thorough macOS note misses), and it uses set -u but not the full set -euo pipefail.

Directory Watcher Script #!/usr/bin/env bash watch-dir.sh — Watch a directory and print a summary for each new file. Usage: ./watch-dir.sh /path/to/directory set -u WATCH_DIR="${1:-}" if [[ -z "$W...
anthropic/claude-fable-5 · 2026-06-11
high7.7

Judge: Complete dependency-free polling watcher: waits for the directory, tracks seen files in an associative array, uses find -print0 for special-character safety, and prints all four required fields. Drawbacks: GNU-only stat -c/numfmt (breaks on macOS), unbounded 'seen' growth, a fixed 1s settle delay as the only partial-write guard, and recreated same-name files are never re-reported. Clean set -euo pipefail style and clear notes.

#!/usr/bin/env bash set -euo pipefail WATCH_DIR="${1:-/path/to/watch}" Wait for the directory to exist while [[ ! -d "$WATCH_DIR" ]]; do echo "Waiting for directory to appear: $WATCH_DIR" sleep ...
openai/gpt-5.4-mini · 2026-06-10
DeepSeek V4DeepSeek
high7.3

Judge: A solid bash script: waits for the directory to exist, uses inotifywait on close_write/moved_to (smartly avoiding partially-written files), and prints filename, human-readable size, file type, and SHA-256 — all hard constraints met. Robustness is reasonable (tool checks, IFS-safe reads handling spaces, vanished-file guard) but it's Linux-only, dies silently if the directory is later deleted, and du reports disk usage rather than apparent file size. Quoting is correct throughout, though there's no set -euo pipefail; the accompanying explanation is clear and well-organized.

Below is a Bash script that monitors a directory for new files (waiting if the directory does not exist) and prints a summary for each newly closed or moved-in file. The summary includes filename, hum...
deepseek/deepseek-v4-pro · 2026-06-10
o4-miniOpenAI
medium7.2

Judge: A solid bash script that handles the missing-directory case via inotifywait on the parent. Uses set -euo pipefail, proper quoting, and checks for required commands. Displays all four required summary fields. Main limitation: inotifywait is Linux-only (not available on macOS), and the script uses Linux-specific stat flags (-c '%s'). Race conditions with rapid file creation are partially handled but not robustly addressed.

Here’s a standalone Bash script. Save it as, say, watch_new_files.sh, make it executable (chmod +x), and then run it with the directory you want to watch as its only argument. It will wait for the dir...
openai/o4-mini · 2026-03-02
high7.0
Run 1 of 2

Judge: Complete, well-structured bash script using inotifywait. Handles directory creation with mkdir -p, prints filename/size/type/SHA-256. Good error handling, proper quoting, command existence checks. However, relies on Linux-only inotifywait (not portable), verbose explanation padding, and lacks set -euo pipefail. The response itself is truncated in the explanation section but the script is complete.

This Bash script uses inotifywait to monitor a specified directory for new file creations. When a new file appears, it extracts its filename, size, type, and SHA-256 hash, then prints a formatted summ...
gemini/gemini-2.5-flash · 2026-03-02avg: 8.1
Claude OpusAnthropic
medium6.4
Run 1 of 2

Judge: Handles directory creation, includes argument validation, has a human-readable size function with fallback. Response truncated but visible portions show reasonable bash scripting with proper quoting. Missing set -euo pipefail at the top. The cross-platform size detection (numfmt vs ls fallback) is a nice touch but the stat syntax shown is Linux-specific (not macOS compatible).

Here's a Bash script that watches a directory for new files and prints summaries: #!/bin/bash Check if directory path is provided if [ $# -eq 0 ]; then echo "Usage: $0 <directory_path>" exit...
anthropic/claude-opus-4-20250514 · 2026-03-01avg: 8.0
Claude HaikuAnthropic
medium5.6
Run 1 of 2

Judge: Truncated but shows strong bash fundamentals: set -euo pipefail, proper quoting, handles both macOS and Linux stat, human_readable_size function, checks for directory existence. The polling approach with tracking file is reasonable. Handles missing files. Cut off before SHA-256 hash section, but the visible code is production-quality bash.

Directory Watcher Script Here's a comprehensive Bash script that watches a directory and prints summaries of new files: #!/bin/bash #################################################################...
anthropic/claude-haiku-4-5-20251001 · 2026-03-01avg: 5.8
Claude SonnetAnthropic
medium5.4
Run 1 of 2

Judge: Reasonable bash script structure with proper quoting and functions. Handles the directory-not-existing case with a polling loop. However, uses inotifywait (Linux-only) without mentioning portability, uses sha256sum instead of shasum (platform-dependent), and the response is truncated before the main watch loop. The dependency check function is a good practice. Missing set -euo pipefail.

Here's a Bash script that watches a directory and prints a summary when new files appear: #!/bin/bash Default directory to watch (current directory if not specified) WATCH_DIR="${1:-.}" Function to...
anthropic/claude-sonnet-4-20250514 · 2026-03-01avg: 6.7
Phi-4Microsoft
medium4.8
Run 1 of 2

Judge: Meets hard constraints: bash script, handles missing directory (mkdir -p), displays all four required fields. Uses set -euo pipefail which is good practice. However, relies on inotifywait (Linux-specific, not available on macOS), uses Linux-specific stat flags, and moves files to a _processed directory which is a questionable design choice not requested. The globbing approach could miss files that appear between iterations.

Helper: #!/bin/bash set -euo pipefail shopt -s nullglob globstar if [[ $# < 1 ]]; then echo 'Usage: watch_dir DIRECTORY' >&2 exit 1 fi DIRECTORY="$1" Ensure the directory exists mkdir -p ...
ollama/phi4 · 2026-03-01avg: 4.1
GPT-4oOpenAI
high4.5

Judge: Functional script that handles directory creation and uses inotifywait for file watching. However, uses Linux-only tools (inotifywait, GNU stat, numfmt) without noting portability issues, lacks set -euo pipefail, and has quoting issues in the while-read loop that would break on filenames with spaces.

Certainly! Below is a Bash script that watches a specified directory for new files and prints a summary for each new file. The summary includes the filename, file size in a human-readable format, the ...
openai/gpt-4o · 2026-03-01
DeepSeek R1DeepSeek
medium4.4

Judge: The script is truncated mid-output, cutting off during the human-readable size calculation. What's visible shows good practices: command existence checks, directory wait loop, inotifywait usage, and quoting. However, the response is incomplete -- we can't verify it displays all required fields (filename, size, file type, SHA-256). Uses Linux-specific tools (inotifywait, numfmt) without noting macOS incompatibility. The truncation significantly limits the grade.

Here's a Bash script that monitors a directory and prints file summaries when new files appear: #!/usr/bin/env bash Check for required commands for cmd in inotifywait stat file sha256sum; do if ...
deepseek/deepseek-reasoner · 2026-03-02
high2.4
Run 1 of 2

Judge: Script has multiple issues: uses 'convert-size --si' which is not a standard utility, uses Linux-specific 'stat -c%s' (won't work on macOS), uses inotifywait without checking if directory exists first (the prompt specifically requires handling missing directory). The find command after inotifywait rescans all files rather than just new ones. No set -euo pipefail, no proper error handling.

Hard constraint failed: Must handle directory not existing yet -- script calls inotifywait on the directory without checking existence or waiting for it to be created.
#!/bin/bash Define a function to calculate the SHA-256 hash of a file calculate_sha256() { local filename="$1" local output=$(sha256sum "$filename") echo "${output%% *}" } Define a function to...
ollama/llama3.1:8b · 2026-03-01avg: 2.6
GPT-5.5OpenAI
high0.0

Judge: The model produced no output at all. Every hard constraint is violated and there is nothing to evaluate, so all dimensions score zero.

Hard constraint failed: The response is completely empty — there is no bash script, no handling of a missing directory, and no display of filename, size, file type, or SHA-256 hash.
openai/gpt-5.5 · 2026-06-10