Ad space (top)
Home β€Ί Prompt Library β€Ί Prompt for Writing a Bash Script

Prompt for Writing a Bash Script

Get a robust, commented bash script for an automation task, with error handling built in.

Coding Β· Works great in Any AI

Copy-ready prompt

Write a bash script that [task].
Environment: [OS/shell, any tools available].
Requirements:
- Use 'set -euo pipefail' and handle errors.
- Add comments explaining each section.
- Validate inputs/arguments.
- Make it safe (quote variables, avoid destructive defaults).
- Include usage instructions.

Want a version tailored to you?

Answer a few quick questions and the Code Prompt Generator builds a custom prompt from your exact details.

πŸ’» Open the Code Prompt Generator
Ad space (inline)

Why this prompt works

Quick bash scripts often break on edge cases or do something destructive. This prompt bakes in strict mode, input validation, and safe quoting, producing a script you can actually rely on in automation.

How to customize it

  • State your OS/shell; bash differs from zsh and sh.
  • Review any destructive commands before running.
  • Test on sample data first, especially for file operations.

Tip: replace the parts in [square brackets] with your own details before you send. The more specific you are β€” audience, tone, goal, constraints β€” the better the AI output.

Ad space (sidebar)