Posted on
Artificial Intelligence

Artificial Intelligence Bash Projects for Your Portfolio

Author
  • User
    linuxbash
    Posts by this author
    Posts by this author

Artificial Intelligence Bash Projects for Your Portfolio

Your terminal is more than a place to run commands—it’s a canvas. If you’re building a portfolio to break into AI or to level up as a DevOps/ML engineer, AI-infused Bash projects show you can ship tools that are reproducible, automatable, and friendly to real production stacks. The problem most beginners face is thinking AI means big frameworks and heavy UIs; the reality is you can stitch together powerful models with small, sharp Bash scripts and a few well-chosen CLI tools.

Below are four practical, resume-worthy AI projects that run from the shell, complete with installation steps and ready-to-commit scripts.


Why AI + Bash belongs in your portfolio

  • Glue power: Bash excels at gluing tools together—LLMs, transcribers, logs, and Git—into workflows hiring teams can run quickly.

  • Reproducibility: Shell scripts, system packages, and small virtual environments are easy to rebuild and test in CI/CD.

  • Automation-ready: Cron, systemd timers, and Git hooks can turn experiments into reliable utilities.


Prerequisites: system packages

Install commonly used packages with your distro’s package manager.

  • Debian/Ubuntu (apt):
sudo apt update
sudo apt install -y curl jq git python3 python3-venv python3-pip ffmpeg
  • Fedora/RHEL/CentOS Stream (dnf):
sudo dnf install -y curl jq git python3 python3-pip ffmpeg
  • openSUSE (zypper):
sudo zypper ref
sudo zypper install -y curl jq git python3 python3-pip ffmpeg

Optional (only if pip complains about building native extensions, e.g., for scikit-learn):

  • apt:
sudo apt install -y build-essential python3-dev
  • dnf:
sudo dnf install -y @development-tools python3-devel
  • zypper:
sudo zypper install -y -t pattern devel_C_C++ python3-devel

Project 1: Terminal text summarizer with a local LLM (Ollama + Bash)

Value: Turn long docs or logs into crisp summaries right in your terminal. Great for demos, support workflows, or team knowledge capture.

1) Install Ollama (Linux):

curl -fsSL https://ollama.com/install.sh | sh

2) Pull a model (choose one; llama3 is a solid default):

ollama pull llama3

3) Create summarize.sh:

#!/usr/bin/env bash
set -euo pipefail

MODEL="${MODEL:-llama3}"

usage() {
  echo "Usage: $0 [file] < input"
  echo "Example: $0 README.md"
  echo "         cat long.txt | $0"
}

if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
  usage; exit 0
fi

# Read input from a file if given, else from stdin
if [[ -n "${1:-}" && -f "$1" ]]; then
  CONTENT="$(cat "$1")"
else
  # readall from stdin
  if [ -t 0 ]; then
    usage; exit 1
  fi
  CONTENT="$(cat)"
fi

# Build the prompt and pipe to ollama
{
  printf "Summarize the following text into 5-7 concise bullet points with key facts and numbers. "
  printf "Keep it under 150 words and avoid speculation.\n\n"
  printf "%s\n" "$CONTENT"
} | ollama run "$MODEL"

4) Make it executable:

chmod +x summarize.sh

5) Use it:

./summarize.sh README.md
journalctl -u docker -n 500 -o cat | ./summarize.sh

Portfolio tip: Add before/after examples to your repo so reviewers can see the improvement at a glance.


Project 2: Voice notes to text (Whisper CLI + Bash), optional auto-summary

Value: Turn spoken updates or standups into text and summaries you can paste into tickets or send to your team.

1) Create a lightweight venv and install Whisper (the package includes a CLI):

python3 -m venv ~/.venvs/whisper
~/.venvs/whisper/bin/pip install -U pip setuptools wheel
~/.venvs/whisper/bin/pip install -U openai-whisper

2) transcribe.sh:

#!/usr/bin/env bash
set -euo pipefail

VENV="${HOME}/.venvs/whisper"
WHISPER="${VENV}/bin/whisper"
MODEL_SIZE="${MODEL_SIZE:-small}"   # tiny, base, small, medium, large
LANG="${LANG:-en}"                  # set your language code if known

if [[ $# -lt 1 ]]; then
  echo "Usage: $0 <audiofile.wav|mp3|m4a|ogg> [--summarize]"
  exit 1
fi

AUDIO="$1"
SUMMARIZE="${2:-}"

# Ensure venv exists
if [[ ! -x "$WHISPER" ]]; then
  echo "Whisper CLI not found at $WHISPER" >&2
  exit 2
fi

# Transcribe (outputs .txt in current dir)
"$WHISPER" "$AUDIO" --model "$MODEL_SIZE" --language "$LANG" --task transcribe --output_format txt --output_dir .

TXT_OUT="$(basename "$AUDIO").txt"
echo "Transcription saved to $TXT_OUT"

# Optional: summarize via Ollama if requested
if [[ "$SUMMARIZE" == "--summarize" ]]; then
  if ! command -v ollama >/dev/null 2>&1; then
    echo "Ollama not found; skipping summary." >&2
    exit 0
  fi
  echo "Summary:"
  cat "$TXT_OUT" | ollama run "${MODEL:-llama3}" <<'PROMPT'
Summarize the following transcript into:

- A 3–5 bullet executive summary

- Action items with owners (if stated)

- Dates or deadlines (if present)
Keep the total under 120 words.
PROMPT
fi

3) Make it executable and run:

chmod +x transcribe.sh
./transcribe.sh meeting.m4a --summarize

Portfolio tip: Include a sample audio file (or a short synthetic one) and the produced transcript/summary to make the repo self-demonstrating.


Project 3: AI-powered Git commit message generator (Git hook + LLM)

Value: Enforce clearer commits automatically. This is a practical dev productivity tool that shows you can enhance developer workflows responsibly.

1) Ensure you have an Ollama model ready:

ollama pull llama3

2) Create .git/hooks/prepare-commit-msg in your repo:

#!/usr/bin/env bash
set -euo pipefail

MSG_FILE="$1"
SRC="${2:-}"

# Skip for merges/squashes or if a message already exists
case "${SRC:-}" in
  merge|squash) exit 0 ;;
esac
if [[ -s "$MSG_FILE" ]]; then
  exit 0
fi

if ! command -v ollama >/dev/null 2>&1; then
  # No AI available; leave message empty
  exit 0
fi

DIFF="$(git diff --staged --unified=0 || true)"
if [[ -z "$DIFF" ]]; then
  exit 0
fi

TMP_OUT="$(mktemp)"
{
  echo "Write a clear Conventional Commit message based on this staged diff."
  echo "- Use a concise <type>(scope): subject on the first line (<= 72 chars)"
  echo "- Provide a short body with wrapped lines (<= 72 chars)"
  echo "- Types: feat, fix, docs, style, refactor, perf, test, chore"
  echo "Diff starts below this line:"
  echo "-----"
  echo "$DIFF"
} | ollama run "${MODEL:-llama3}" > "$TMP_OUT" || true

# If we got something, append to commit message
if [[ -s "$TMP_OUT" ]]; then
  cat "$TMP_OUT" >> "$MSG_FILE"
fi
rm -f "$TMP_OUT"

3) Make it executable:

chmod +x .git/hooks/prepare-commit-msg

Try a change, stage it, and run git commit. You’ll get an AI-suggested message you can edit before saving.

Portfolio tip: Add screenshots or terminal recordings (e.g., asciinema) showing the hook in action.


Project 4: Log anomaly detector (Isolation Forest + Bash)

Value: Spot unusual log lines quickly as part of on-call or post-incident workflows. This demonstrates practical ML applied to ops.

1) Create a venv and install scikit-learn:

python3 -m venv ~/.venvs/anom
~/.venvs/anom/bin/pip install -U pip setuptools wheel
~/.venvs/anom/bin/pip install -U scikit-learn

2) detect_anomalies.py:

#!/usr/bin/env python3
import sys
import argparse
from sklearn.ensemble import IsolationForest
from sklearn.feature_extraction.text import TfidfVectorizer
import numpy as np

parser = argparse.ArgumentParser()
parser.add_argument("--top", type=int, default=20, help="How many anomalies to show")
args = parser.parse_args()

lines = [ln.rstrip("\n") for ln in sys.stdin if ln.strip()]
if not lines:
    sys.exit(0)

# Char n-grams work well for logs with varying tokens
vec = TfidfVectorizer(analyzer="char", ngram_range=(3,5), min_df=2)
X = vec.fit_transform(lines)

# Low contamination => fewer anomalies
iso = IsolationForest(n_estimators=200, contamination=0.02, random_state=42)
scores = iso.fit_predict(X)  # -1 for anomalies, 1 for normal
decision = iso.decision_function(X)  # lower => more anomalous

# Rank by anomaly score
idx = np.argsort(decision)  # ascending; most negative first
top_n = min(args.top, len(lines))
print(f"Top {top_n} anomalous lines:")
for i in idx[:top_n]:
    print(f"[score={decision[i]:.4f}] {lines[i]}")

3) scan-logs.sh:

#!/usr/bin/env bash
set -euo pipefail

VENV="${HOME}/.venvs/anom"
PY="${VENV}/bin/python"

TOP="${TOP:-20}"
COUNT="${COUNT:-1000}"  # how many recent lines to scan

if [[ ! -x "$PY" ]]; then
  echo "Python venv not found at $VENV. Create it first." >&2
  exit 1
fi

# Prefer systemd journals; fallback to syslog files if needed
if command -v journalctl >/dev/null 2>&1; then
  LOGS="$(journalctl -n "$COUNT" -o cat || true)"
else
  # Try common log file (adjust for your distro/app)
  LOGS="$(tail -n "$COUNT" /var/log/syslog 2>/dev/null || tail -n "$COUNT" /var/log/messages 2>/dev/null || true)"
fi

if [[ -z "$LOGS" ]]; then
  echo "No logs found or insufficient permissions." >&2
  exit 0
fi

printf "%s\n" "$LOGS" | "$PY" detect_anomalies.py --top "$TOP"

4) Make scripts executable:

chmod +x detect_anomalies.py scan-logs.sh

5) Run it:

./scan-logs.sh
COUNT=5000 TOP=50 ./scan-logs.sh

Portfolio tip: Include a synthetic log generator in your repo that injects rare patterns so reviewers can reproduce anomaly detections deterministically.


Packaging and polish ideas

  • Add help flags and usage docs to each script.

  • Provide example inputs/outputs in an examples/ directory.

  • Include a Makefile with targets like setup, test, demo.

  • Wire a cron job or systemd user timer for scheduled runs (e.g., nightly log scans).

  • Add a short README section on security/privacy and model choices.


Conclusion and next step

AI from the command line isn’t just possible—it’s practical. These four projects showcase real-world value: summarizing text, transcribing meetings, upgrading commit hygiene, and finding weirdness in logs. Pick one, turn it into a tidy repo with a README and demos, and share it. When you’re ready, combine them into a cohesive toolkit and write a short blog post describing your design choices.

Call to action: Choose one project above, fork it into your own GitHub repo today, and add a 2-minute demo recording. Your future self—and future reviewer—will thank you.