Skip to content
PromptLab by FEHMER TECH
ENDE
Coding

Shell Script Creation

Create robust shell scripts for automation and system administration.

Prompt template

Create a robust shell script (Bash) for [TASK DESCRIPTION].

**Requirements:**
- Target system: [Linux/macOS/both]
- Required tools: [TOOLS THAT MUST BE AVAILABLE]
- Execution: [Manual/Cron/Systemd]

**The script should include:**
1. **Shebang and Strict Mode:** set -euo pipefail
2. **Argument Parsing:** Processing of flags and positional arguments
3. **Validation:** Check all prerequisites (tools, permissions, files)
4. **Error Handling:** Trap handlers for cleanup on errors
5. **Logging:** Colored output with timestamps and log levels
6. **Configuration:** Support for config files and environment variables
7. **Main Logic:** [DESCRIPTION OF FUNCTIONALITY]

**Best Practices:**
- Use functions for modular structure
- Quote all variables correctly
- Use $(command) instead of backticks
- Implement a --help option
- Support --dry-run for safe test runs
- Use temporary files safely with mktemp

Comment every important section.

Replace placeholders in [square brackets]: [TASK DESCRIPTION][Linux/macOS/both][TOOLS THAT MUST BE AVAILABLE][Manual/Cron/Systemd][DESCRIPTION OF FUNCTIONALITY]

How to use this template

Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.

Tips for better results

  • Specify the target system and required tools
  • Mention whether the script runs via cron or manually
  • Ask for a --dry-run option for safe testing
  • Request a Makefile or installation guide

Suitable open models

The selection names current open models as a starting point for your own tests. It is not a measurement for this template.

Keywords: #shell #bash #automation #sysadmin

Last updated: