Explain Bash code

Paste a shell script or a one-liner and Vibe explains what it does before you run it.

top-errors.sh

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Google Gemini to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe19 lines selected

Press Explain it for the sample, or paste your own code first.

What this Bash sample shows

pipes
Each | sends one command's output into the next: grep keeps the error lines, cut drops the date and time, sort | uniq -c counts repeats, sort -rn puts the biggest count first and head keeps 10.
redirection
> "$report" writes the result to a file instead of the screen. >&2 sends the error message to standard error, so it still shows when the normal output is redirected.
variables
${1:-/var/log/myapp} uses the first argument, or that folder when none is given. $(date +%F) runs date and puts its output, such as 2026-10-25, into the file name.
exit codes
exit 1 tells whatever ran the script that it failed. set -e stops at the first failing command, -u treats unset variables as errors and -o pipefail makes a pipeline fail when any part of it fails.

Good to know

  • The quotes in "$log_dir" keep a folder name with spaces as one argument. *.log stays outside the quotes so the shell can expand it into file names.
  • cut -d' ' -f3- assumes every line starts with a date and a time separated by spaces. Logs in another format need a different field number.
  • If the folder has no .log files, the pattern stays as the literal text *.log, grep can't open it and the script stops with exit code 2.

Watch out: If no line contains ERROR, grep exits with 1, pipefail fails the pipeline and set -e ends the script before the last echo, leaving an empty report. Add || true after the pipeline if no errors is a normal result.

Explain Bash code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).