TechRetriever
Workflows

Create bash script files you can read and test

03
A repeated chore

From a repeated chore to a script

People who search for 'create bash script' or 'write bash script' usually have one chore they repeat by hand, such as counting log files in a folder. Start with one chore. The goal is a file you can read, test and run again, and here the agent drafts it, checks the syntax and shows each result as a card.

01

Open the project folder

Choose the folder that holds your scripts, or an empty one, as the chat's working folder. File tools work inside it.

02

Describe the job

Say what the script should read, what it should print and what it must not change, for example a read-only count of log files.

03

Review the plan

Pick Plan only to have the script explained without running it, or Ask first to approve each action that changes something.

04

Run and check

Run bash -n, then a trial on a test folder, and compare each card's output and exit code with what you expected.

A read-only example you can copy

count-logs.sh
#!/usr/bin/env bash
# count-logs.sh - count lines in .log files of a folder
# usage: bash count-logs.sh [folder]   (read-only)
set -eu

dir="${1:-.}"
count=$(find "$dir" -maxdepth 1 -name "*.log" | wc -l)
echo "found $count log file(s) in $dir"
for file in "$dir"/*.log; do
  [ -e "$file" ] || continue
  wc -l "$file"
done

The script counts .log files with find and prints the line count of each with wc. It only reads, and set -eu makes the shell stop on an unset variable and on most failing commands.

Two scripts to build next

Get feedback on your first Bash script

Paste your own draft into the working folder and ask the agent to review it. read_file loads the script, grep finds the places where a variable is used, and the agent points out missing double quotes, unchecked arguments and unclear names. The same review works on your Bash startup file: ask which commands in it run on every start. In Plan only the agent explains the script without running it. When you ask for fixes, edit_file shows every change as a diff, and you accept it only after you understand it.

Build a countdown timer

A simple Bash timer script for beginners needs only a variable, a for loop, echo and sleep. Ask the agent for a countdown that takes the number of seconds as $1 and prints the seconds left. write_file saves countdown.sh, and Shell runs bash -n and then a trial with a small number such as 3. Because sleep only waits, the script changes nothing on disk. Ideas like converting images to ASCII with Bash build on the same loops and variables, though image formats need extra care. Watch the output card, check the exit code and read the code before you reuse it.

TechRetriever for Windows

Run your first script on a test machine

Download TechRetriever ↗