r/bash

Free online editor where you can write Bash scripts, run them, take notes, and export to PDF
▲ 9 r/bash

Free online editor where you can write Bash scripts, run them, take notes, and export to PDF

Built an online editor that supports writing and executing Bash scripts directly in the browser. Useful if you want to combine runnable code with your own notes in one document.

Try it: https://8gwifi.org/math/editor.jsp

What it does:

  • Write Bash scripts in runnable code blocks — select Bash from the dropdown or let it auto-detect
  • Click Run (or Ctrl+Enter) to execute and see stdout/stderr inline
  • Stdin input toggle for scripts that use read
  • Mix code blocks with formatted text, headings, tables, and diagrams
  • Export the whole document as PDF or LaTeX
  • Share documents via link (public, unlisted, or private)
  • Auto-saves to your browser

Good for:

  • Building a Bash cheat sheet with runnable examples you can actually test
  • Learning string manipulation, arrays, pipes, awk, sed — run each snippet as you go
  • Creating DevOps runbooks that mix documentation with executable commands
  • Sharing tutorials or study notes with teammates

Example topics covered in a single document:

  • Variables and quoting ($var${var}, single vs double quotes)
  • Conditionals and loops (if/elif/elseforwhile)
  • Functions with arguments and return values
  • String operations (${#str}${str^^}${str/old/new})
  • Arrays and slicing
  • Pipes and text processing (grepsortawk)
  • Reading stdin with read

Try it: https://8gwifi.org/math/editor.jsp

Insert a code block from the toolbar (the </> button) or type / and select "Code Block". Pick Bash from the language dropdown and start scripting.

No signup required. Free.

u/anish2good — 7 hours ago
▲ 3 r/bash

Is using $SHLVL a good way to tell if a script is running in a terminal window?

So, I want to make it so that a script I'm running will ONLY run in a terminal window, and will sleep for 3 seconds then exit if it's not in a terminal window. I've done a little bit of looking, but I'm not entirely sure if it would work as I intend, and if there are ways in which it could fail/if there are more reliable methods.i was thinking of something along the lines of:

If $SHLVL > 1 then
    Echo running in terminal
    Echo continuing
Elif $SHLVL =< 1 then
    Sleep 3
    Exit
Else
    Echo how is this even possible?
Fi

(Obviously that's not correct syntax, it's just the general structure/idea of what I want to do) I'm not at my PC rn (on a road trip) but I'm trying to write a general test script on my phone that I can test on my PC once I return home.

reddit.com
u/C4n7_7h1nk_0f_n4m3 — 23 hours ago
Week