Need help with a sed command for a workflow
Hello! I need some help with a `sed` command for a GitHub (it's actually Forgejo but it's the same thing in practice) workflow I'm writing. I'm trying to align the version number in my "Cargo.toml" file with the release tag using the following command but it's not working: `sed -i '3s/.\*/version: "$TAG"/' Cargo.toml`.
Here is a bit more of the context if it is helpful, though I doubt it would be:
- name: Bump version, tag it, and push
id: bump
shell: bash
run: |
if ! cog bump --auto --dry-run >/dev/null 2>&1; then
echo "Nothing to release"
echo "released=false" >> "$GITHUB_OUTPUT"
exit 0
fi
cog bump --auto
TAG=$(git describe --tags --abbrev=0)
if ${{ inputs.align-cargo }} == 'true'; then
echo "Aligning cargo"
sed -i '3s/.*/version: "$TAG"/' Cargo.toml
echo "Updated Cargo.toml (first few lines):"
head Cargo.toml
git add Cargo.toml
echo "Resuming main flow"
fi
git push origin HEAD
git push origin "$TAG"
if [ "${{ inputs.move-major-tag }}" = 'true' ]; then
MAJOR="${TAG%%.*}"
git tag -f "$MAJOR" HEAD
git push -f origin "$MAJOR"
fi
echo "released=true" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
Honestly I've always kind of avoided sed and just used vi or nano instead, so any help would be greatly appreciated.
https://redd.it/1xiih9p
@r_bash
Which terminal?
Which terminal do you use, and why?
I've tried a good handful of terminals, and I'm currently using WezTerm. So far, though, I'm not enjoying it quite as much as I did Alacritty or Kitty.
The main reason I'm giving WezTerm a shot is its flexibility. From what I've read, it seems like one of the most capable terminals out there if you're willing to put in the time to customize it. It sounds like it can do just about everything the other terminals offer, all in one package.
I'm curious what everyone else uses and what made you settle on it. Is there something about your terminal that makes it worth sticking with over the alternatives?
https://redd.it/1xh2v4z
@r_bash
Improve your Bash testing with Bats
I started solopreneuring a year ago, and my projects have a fair amount of Bash. My annoyances with Bats: I couldn't mock things efficiently, the assertion libraries are scattered over three repos with different naming, and table-driven tests are clumsy. I've written these scripts over the years in my career and thought about open-sourcing them, but never did. I'm using these libraries in my own frameworks and it helps me test my bash scripts in a more unified way, so I've chosen to productionize them and finally putting it out there:
bats-mock mocks and spies on commands and Bash functions. You set behavior with glob/regex rules, run your code, then assert on call counts, exact argv, stdin and call order across commands. Spies call through to the real thing. jasonkarns/bats-mock uses stubs on PATH, so it can't mock a function without unsetting it, and has no spies or stdin checks.
https://github.com/stealth-scale/bats-mock
bats-expect replaces bats-support, bats-assert and bats-file with one library. bats-assert's functions keep their names, options and failure format, so switching is a one-line change. Naming is consistent, and it adds assertions for variables, arrays, namerefs, numbers and JSON.
https://github.com/stealth-scale/bats-expect
bats-matrix does table-driven tests: inputs, expected exit status and expected output in one table, and a failure tells you which row broke and the exact command it ran. Bats' own bats_test_function works too, but needs a loop and a separate test body.
https://github.com/stealth-scale/bats-matrix
bats-test is the image I run it all in: every combination of Bash 4.4/5.1/5.2/5.3 and Bats 1.7.0/1.14.0, GNU tools, jq and a patched kcov.
https://github.com/stealth-scale/bats-test
I've been an engineer for a long time and I care about quality, so my libraries have a 100% line coverage gate in CI. That's how I ended up in a kcov rabbit hole: on Bash 5.3 one suite came out at 0%. kcov's Bash support had three bugs: a single quote inside [[ \]\] made it drop every later hit, it counted every line of a multi-line command while Bash reports one, and its helper killed any bash -c child running with set -u. With the fixes, bats-mock went from 659 lines at 88% to 613 at 100%. The patches are in bats-test. I haven't sent them upstream yet, and I know I should.
If you don't mind switching frameworks, bashunit and ShellSpec already have mocks and data-driven tests. These repos are for staying on Bats.
The linked repo is a small release CLI whose test suite uses all four:
git clone --recurse-submodules https://github.com/stealth-scale/bats-example.git && cd bats-example && make test
It uses Podman (make test RUNTIME=docker for Docker) and runs without network. You need Bash 4.4+, and since the mocks are functions, /usr/bin/curl goes straight past them.
Everything is MIT (the image ships kcov, which is GPL-2.0). For me these tools are a big time-saver.
I'd love to hear what's still annoying to test in your Bash so I can further improve what I've used for years.
https://redd.it/1xgnn8p
@r_bash
First time learning Bash: macOS vs Linux VM?
I'm learning Bash via Codecademy(maybe, idk if I'll pay for the subscription) and LinkedIn Learning. The specific course I'm starting says macOS is okay but using a Linux VM with something like Virtual Box is preferred since Linux is industry standard.
I haven't worked with VMs before but it is also something I want to learn about, but I don't know what the curve is like for setting something like this up or if it's worth doing as a beginner.
What do y'all recommend?
https://redd.it/1xfaz10
@r_bash
automatically write a shortcut to go to a specific directory
I personally have found that on linux systems, the biggest number of aliases are simply "alias <name> = 'cd <path>'", so it makes sense then to automate this. I wasn't interested making a github repository since this is very simple, and i would expect someone like me to perhaps make a slightly different version of this for whatever they do:
#!/bin/bash
#adds an alias to traverse a directory
if "$#" -ne 2 ; then
echo "Number of argments entered is $#, needs"
echo "exactly 2 arguments to run."
echo
echo "usage: add-alias.sh <alias> <directory-path>"
exit
fi
if "$1" = "-h" ; then
echo "usage: add-alias.sh <alias> <directory-path>"
exit
fi
ALIAS="$1"
DIRECTORY="$2"
echo "alias $ALIAS='cd \""$DIRECTORY"\"'" >> ~/.bashaliases
echo "Written to .bashaliases: alias $ALIAS='cd \""$DIRECTORY"\"'"
the thing that was fun about making this was figuring out the exact quoting to make it work, as some directories are inevitably going to have spaces etc.
https://redd.it/1xdxpbe
@r_bash
just beautiful way = ) tail -F $(lsof|grep log|awk '{print $9}'|grep '\.log$')
have s nice time
https://redd.it/1xcpm70
@r_bash
set -e silently does nothing inside a function called from an if, and I only found out in production
I had a cleanup script that always started with the usual `set -euo pipefail`. One day it reported success while half the work hadn’t happened. Here’s a stripped-down version of what bit me:
#!/usr/bin/env bash
set -euo pipefail
cleanup_old() {
rm "$1/old.log" # fails if the file is missing
echo "cleaned $1"
}
if cleanup_old /tmp/nope; then
echo "all good"
fi
Output:
rm: cannot remove '/tmp/nope/old.log': No such file or directory
cleaned /tmp/nope
all good
The `rm` fails, but the function keeps going, and the `echo` at the end gives it a zero exit status. The bash manual says `-e` is ignored for any command in a context where the exit status is being tested (`if`, `while`, `&&`/`||` lists, `!`). That also applies to everything inside a function called from such a context. `set -e` at the top of the file doesn’t help, and nothing warns you.
What I do now:
cleanup_old() {
rm "$1/old.log" || return 1
echo "cleaned $1"
}
The explicit `|| return` is noisier, but it works regardless of how the function gets called. For anything where partial success is dangerous, I also stopped using functions as `if` conditions and run them as plain statements, checking `$?` or using `||` on the call site deliberately.
Related one that bit me the same week: `local out=$(some_cmd)` always returns the exit status of `local`, not `some_cmd`. Splitting it into `local out; out=$(some_cmd)` fixes it.
I’ve been reading a lot of generated and copy-pasted scripts lately, and nearly all of them treat `set -euo pipefail` as a safety net. After this, I think of it as a default that works in the simple cases and quietly stops working in exactly the places where functions get composed.
For those who write larger bash scripts: do you rely on `set -e` at all, or do you handle errors explicitly everywhere and keep `-e` only as a backstop?
https://redd.it/1xbmggr
@r_bash
through as local time with a separate `dtstart_tzid` field.)
Full write-up, which also covers headerless CSV/TSV files: [JC Tips and Tricks – Part 3](https://blog.kellybrazil.com/2026/10/19/jc-tips-and-tricks-part-3/)
What file formats are you still parsing by hand in your scripts?
https://redd.it/1xb00um
@r_bash
I Made a yt-dlp script
First of all, please excuse my English. I’m using a translator, sorry! :(
I’m a regular user of the tool yt-dlp, but it can sometimes be a bit complicated to use. I’ve created a Bash script built WITHOUT AI (it’s wild that we even have to specify this nowadays...) that makes it easier to use. It’s currently in Spanish, but I’ll be adapting it into English over the next few days. Don’t worry, it’ll only take me a few minutes.
I’m sharing it in case anyone finds it useful! :)
Here’s the Codeberg repository:
https://codeberg.org/elrefugiodeunnerd/simple-yt-dlp-script
https://redd.it/1xaz66b
@r_bash
Need help with small issue that pisses me off
/r/KittyTerminal/comments/1x91gba/need_help_with_small_issue_that_pisses_me_off/
https://redd.it/1xaedn2
@r_bash
Help: Does anyone use AI to assist with making Scripts
Does anyone use AI to assist with making bash scripts? I just want to hear y'all opinion on it.
https://redd.it/1x9b044
@r_bash
rethinking bash2json: introducing shelljq
https://github.com/Tirito6626/shelljq
https://redd.it/1x95tj7
@r_bash
Alias for Safety? Creating Alias for more than one word?
/r/linux4noobs/comments/1x86fbl/alias_for_safety_creating_alias_for_more_than_one/
https://redd.it/1x86fhu
@r_bash
Tinybackup: a tiny Kopia backup wrapper
For all those who want simple backups of their machines, I have created a tiny bash wrapper around Kopia: https://github.com/bderenzo/tinybackup
From a single minimal config file, it handles repository setup, retention, ignore rules and pre/post backup hooks, etc.
It can back up to a local disk, SFTP, S3 or any rclone remote, and lets you browse snapshots through CLI, a mount point or the Kopia web UI.
https://redd.it/1x630n8
@r_bash
Many things could go wrong with this script and leave a running process, how would you recommend fixing this?
#!/usr/bin/env bash
function main() {
# Phase 1: Setup and Run Dev Server
printf "%s\n" "Starting development server..."
cd "$HOME/Desktop/my-project-1" || exit 1
# Run the dev server in the background
rm -rf coverage dist && npm run lint && npm run coverage && npm run test && npx tsc || exit 1
npx tsx watch --env-file=.env.development src/index.ts > "/tmp/server.log" 2>&1 &
DEV_PID=$! # Store the Process ID of the 'dev' server
# Monitor for "server is listening"
printf "%s\n" "Waiting for server startup message..."
while ! grep -q "Server is now listening" "/tmp/server.log"; do
printf "%s\n" "Server not yet ready. Still waiting..."
sleep 1 # Wait 5 seconds before checking the log again
done
printf "%s\n" "SUCCESS: Server is listening. Proceeding to Phase 2."
# Phase 2: API Call and Wait
printf "%s\n" "Executing API call..."
rm -rf /tmp/test_app && curl -X POST http://localhost:3003/job/node/express/basic/generator
# Monitor for "downloading..." message in logs...
printf "%s\n" "Waiting for download completion..."
# Wait for the download confirmation
while ! grep -q "downloading docker container files completed successfully" "/tmp/server.log"; do
printf "%s\n" "Waiting for download confirmation..."
sleep 1
done
# Phase 3: Cleanup
printf "%s\n" "Shutting down services..."
kill ${DEV_PID} # Use the stored PID to gracefully stop the server process
printf "%s\n" "Moving into generated code..."
cd "/tmp/test_app" && npm install && code "/tmp/test_app" && cd "$HOME" || exit 1
}
main "$@"
Working on the Bash interpreter in JavaScript
I'm working on the Bash interpreter (Unix env) and making use of an old domain:
hacking.cafe.
The code is open source on the AGPL license available on GitHub.
I was thinking about making the bash interpreter part a library on a less restrictive license.
The README includes bash features that I've implemented so far.
I'm using ubash JavaScript parser.
https://redd.it/1xh9j4v
@r_bash
Replacing dirname with only builtins
I am writing a bunch of scripts for which I want to only use builtins and realised that dirname is not a builtin, I replaced it thusly:
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DIR2="$({ cd "${BASH_SOURCE[0]%/*}" 2>/dev/null || :; } && pwd)"
BASH_SOURCE[n] will never contain a trailing /.
Race condition with | tee -a >(col -b >> "$f") and following function/command that also appends to $f
I'm writing to file $f using the snippet above, and the command after it also writes/appends to $f.
I'm using col because it's for fio --eta=always to display on terminal but not fill up the file with carriage returns or whatever commands that clutter the file and are intended control for the terminal for the purpose of live status updates.
Running it as in the title, the next command begins before col is done and their respective outputs mix a bit.
I believe the problem is that tee is being recognized as having finished/closed whereas >(col -b >> "$f") isn't being tracked and is still writing. I don't understand fully though I recognize, "The process... is run asynchronously."
I've found two solutions, but they don't quite feel right. Let me know if you can think of a better one or of which these two that you prefer.
{
fio --eta=always "${job}" | tee -a >(col -b >> "$f")
} &
wait $!
or
fio --eta=always "${job}" | tee /tmp/fio.log.tmp
cat /tmp/fio.log.tmp | col -b >> "$f"
rm /tmp/fio.log.tmp
The second one, I could probably add a mktemp and trap to both secure and delete the temp file.
https://redd.it/1xgf6pi
@r_bash
What should i do now
Heyy i am new to Linux(currently using fedora silver blue) and exploring Linux, recently started exploring Bash for interest now i learn little bits of it like(basic commands , file permissions) from web3school , now what should i learn next ? From where(resource)
https://redd.it/1xe5qxi
@r_bash
cz: a cd/zoxide-style directory jumper with live filesystem search (ratatui + nucleo + rusqlite) — beta, feedback welcome
I've been building cz, a directory navigator for bash/zsh, and just released v0.2.1 (beta).
Like zoxide, it learns frecency from your visits; unlike zoxide, it also scans the current scope in the background, so it can find folders you've never visited. `czi` opens a picker that also lists files and cd's to the picked file's folder.
Some Rust details that might be interesting:
* **ratatui** picker that updates live while a background BFS thread streams results over mpsc
* **nucleo-matcher** for fuzzy scoring, combined with a frecency multiplier (exact/prefix/substring tiers)
* **rusqlite** (bundled) for history, static **musl** build, 3.7 MB
* the scanner skips symlink loops, /proc-like and network/FUSE mounts (read from /proc/self/mounts), so `cz -r` never hangs on an sshfs mount
* an "auto-jump" rule that can decide using history alone before the scan finishes, by bounding the best possible score of not-yet-seen directories
Repo : [https://github.com/piumalnipun9/cz](https://github.com/piumalnipun9/cz)
Code review and feedback very welcome, especially on the ranking/auto-jump logic (src/search/) and the scanner (src/search/filesystem.rs).
https://redd.it/1xd8gll
@r_bash
If you're learning Bash or other SRE/Ops skills, please check this out
Hello guys,
I've been working on a project with Claude's help. Yes, I admit it, and I'm not so proud that it's mainly coded by Claude.
But since I like helping people, pixel art, and sharing a bit of what I know and what I learned in my day-to-day job, I made Bashou (https://github.com/IAmAStealer/Bashou).
It gathers a lot of my knowledge and also teaches Bash in general, as well as other subjects you can choose.
It really tries to build things up little by little, teaching good practices and rewarding them. I'm planning to add even more about creating and managing a whole infrastructure, like a simple private cloud.
Please take a quick look and try it. I'll read your reviews with great interest and do my best to reply / fix things. It's a hobby.
About security: the only remote connection is when you download / update it, and that goes through native deb/rpm. You can share your progress: it's encoded JSON that gets decoded on a GitHub page. The only shady part would be something the AI slipped in. I turned on GitHub's scans and had fresh agents review the code, and they couldn't find anything. Nothing is sent online: it uses a hook + your history. Or prove me wrong with tcpdump, as you'll learn it.
Have a nice day all. Thanks for reading.
https://redd.it/1xbxhwe
@r_bash
I built a simple terminal tool to manage AppImages, Flatpak, and APT apps in one place (Beginner Friendly
https://redd.it/1xbja5x
@r_bash
Auditing every user’s authorized_keys in a Bash loop with jc + jq
I maintain [jc](https://github.com/kellyjonbrazil/jc), which converts command output and common file types to JSON so you can query them with `jq` instead of `grep`/`awk`/`cut`. A couple of newer parsers turned out to be handy in Bash scripts, so I wrote up some examples.
**Why not just awk?**
`authorized_keys` looks like a whitespace-delimited file, but it isn't. Lines can start with an optional, comma-separated options field, and option values can be quoted strings with spaces in them. So the field positions shift from line to line. Here's a sample file:
ssh-ed25519 AAAAC3Nza... kelly@laptop
command="/usr/bin/rsync --server --sender -logDtpre.iLsfxC . /srv/backup",no-port-forwarding,no-pty ssh-rsa AAAAB3Nza... backup@nas
from="10.0.8.0/24",no-agent-forwarding ecdsa-sha2-nistp256 AAAAE2Vj... ci-runner@build01
ssh-ed25519 AAAAC3Nza...
The obvious `awk` one-liner to print the key type and comment:
$ awk '{print $1, $3}' ~/.ssh/authorized_keys
ssh-ed25519 kelly@laptop
command="/usr/bin/rsync --sender
from="10.0.8.0/24",no-agent-forwarding AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlz...
ssh-ed25519
Only the first line is right. Looking for RSA keys with `awk '$1=="ssh-rsa"'` returns nothing, because the one RSA key has options in front of it.
`grep` has the opposite problem: it matches text anywhere on the line. `grep -v 'command='` to find unrestricted keys also drops a key whose *comment* says "no command= needed". And `grep ssh-rsa` matches a restricted ed25519 key whose forced command happens to contain the string `ssh-rsa`.
With `jc --authorized-keys`, every line comes out with the same fields, so there's no guessing:
$ jc --authorized-keys < ~/.ssh/authorized_keys | jq -r '.[] | "\(.type) \(.comment // "(no comment)")"'
ssh-ed25519 kelly@laptop
ssh-rsa backup@nas
ecdsa-sha2-nistp256 ci-runner@build01
ssh-ed25519 (no comment)
`options` is always an array, quoted values like `command="echo ssh-rsa disabled; exit"` stay intact, and multi-word comments are kept whole.
**Tag every key with its owner, then query the whole box**
A loop adds a `user` field to each key and emits JSON Lines:
for f in /home/*/.ssh/authorized_keys; do
u=$(echo "$f" | cut -d/ -f3)
jc --authorized-keys < "$f" | jq -c --arg u "$u" '.[] | . + {user: $u}'
done > keys.jsonl
Now each question is just a different `jq` filter. Which keys have no `from=` or `command=` restriction?
jq -r 'select(any(.options[]; startswith("from=") or startswith("command=")) | not)
| "\(.user) \(.type) \(.comment // "(no comment)")"' keys.jsonl
Because this checks the `options` array instead of the whole line, comments and key data can't cause false matches.
Is the same key authorized for more than one user?
jq -s -r 'group_by(.key)[] | select(length > 1)
| "\(.[0].comment // "(no comment)"): \(map(.user) | join(", "))"' keys.jsonl
Which legacy RSA or DSA keys are still around?
jq -r 'select(.type == "ssh-rsa" or .type == "ssh-dss") | "\(.user) \(.comment)"' keys.jsonl
(Run the loop with `sudo` if you need to read other users' files.)
**Bonus: a change-freeze guard from a shared calendar**
`.ics` files are worse for line tools: long lines get folded onto the next line, and parameters are jammed into property names (`DTSTART;TZID=America/Los_Angeles:20261019T090000`). The `--ics` parser unfolds all of that and normalizes timestamps to ISO 8601. That means `jq`'s `fromdateiso8601` and `now` can check whether you're inside a freeze window, and `jq -e` turns the result into an exit code:
if jc --ics < freeze.ics | jq -e '
[.[] | select(.categories[]? == "Freeze")
| select((.dtstart | fromdateiso8601) <= now and now < (.dtend | fromdateiso8601))]
| length > 0' > /dev/null
then
echo "Change freeze in effect. Aborting deploy." >&2
exit 1
fi
(This works with UTC timestamps, the ones ending in `Z`. Events with a `TZID` come
A coding agent in ~60 lines of bash, curl and jq (and the shell tricks it took to get there)
I wanted to understand what tools like Claude Code actually do under the hood, so I built the smallest version I could in plain bash. Three scripts, each adding one idea: a single curl call, then a chat loop, then a "bash" tool the model can call. The last one is a working agent that, when asked, writes and runs a Tetris game in Python.
Repo: https://github.com/antonum/bash-harness
The AI part turned out to be boring: it's a chat loop with an inner loop that runs commands until the model stops asking for them. The interesting part was the bash. A few things I hit that might be useful to others:
**Never put big payloads on the command line.** The conversation gets resent in full on every request and only grows. One `cat` of a large file as an argument blows past ARG_MAX (1 MB on macOS). So the request body is built by jq and piped into curl with `-d @-`, and tool output goes into jq via `--rawfile` from a process substitution:
```bash
add_message --arg id "$call_id" --rawfile c <(printf '%s' "$result") \\
'{role: "tool", tool_call_id: $id, content: $c}'
```
**One generic `add_message` function.** It takes jq args plus a jq object expression, so each call site spells out the exact JSON shape it is appending. No templating, no escaping bugs:
```bash
add_message() {
MESSAGES=$(jq --argjson m "$(jq -nc "$@")" '. + [$m\]' <<<"$MESSAGES")
}
add_message --arg c "$input" '{role: "user", content: $c}'
```
**Capturing output and exit code from an arbitrary command** without tripping `set -e`:
```
run_tool() {
local output status=0
output=$(bash -c "$1" 2>&1) || status=$?
printf '%s\\n[exit code: %d\]' "$output" "$status"
}
```
**Iterating a JSON array one element per line** with `jq -c '.tool_calls[\]'` fed through `done <<(...)`, so the loop body can touch variables in the parent shell.
**`read -e -r -p`** gives you readline editing and history for free in the prompt loop.
**A one-line "thinking" spinner** in a background subshell, killed with `kill $!` when curl returns.
Caveats: it needs bash 3.2+ (runs on stock macOS), jq, curl, and an API key for any OpenAI-compatible endpoint with tool calling, including local models. And obviously script 03 runs whatever the model asks for, with your permissions and no confirmation. It's a tutorial, not a product. Read the commands as they scroll by and don't run it somewhere you care about.
Happy to hear what I got wrong or what you'd do differently. The repo has a "what's next" list (approval prompts, output limits, session resume) if anyone wants to extend it.
https://redd.it/1xarji9
@r_bash
I built a Bash practice site that runs in your browser. Looking for feedback and contributors
Hi everyone! I’ve spent the last few days building learnbash.dev, a site for practising Bash and Linux commands without installing anything or touching your own files.
It runs a real Bash shell on Alpine Linux with GNU tools, entirely in your browser through v86. Each challenge gives you a task, checks the result, and offers hints if you get stuck, followed by an explanation.
There are currently 30 challenges across two parts:
Navigation and files: moving around, reading and editing files, copying, moving, deleting, and working with wildcards.
Investigating an incident: using find, grep, pipes, redirection, sorting, and permissions to work through a small incident scenario.
It’s free, with no accounts or ads, and progress is saved locally in your browser.
I’d appreciate feedback from beginners: are the instructions clear, do the explanations help, and are there places where the difficulty jumps too quickly? If you’re experienced with Bash, corrections to the teaching material and suggestions for better exercises would be especially useful.
For the next section, I’ve drafted exercises on cleaning up text exports with tools like diff, cut, tr, and sed. I want to get feedback on the existing sections before adding more. Longer term, I’d like to cover variables, quoting, scripting, processes and job control, and more involved practical projects.
I’m also exploring networking exercises. For example, running local web and SSH servers inside the VM so learners could practise curl, ssh, scp, and SSH keys without external machines. That still needs prototyping to understand the limitations, performance, and effect on download size.
Contributors are welcome, whether you’re interested in writing challenges, reviewing explanations, fixing bugs, improving tests, or exploring the networking ideas. Challenges use Markdown and small Bash scripts for setup, checking, and reference solutions, so you don’t need frontend experience to help with the exercises. The repository includes authoring docs and a curriculum.
Source: github.com/adneborresen/learnbash.dev
Feel free to open an issue or pull request, or comment here if you’d like to get involved, have feedback or just want to discuss. You can also submit feedback directly through the site.
https://redd.it/1x9wiig
@r_bash
I built a network security suite on my phone using Termux, Java, and Bash. I automated the setup with a single shell script. Ready to get roasted.
https://redd.it/1x92baj
@r_bash
Is this possible? Want to use terminal to show Youtube homepage with slightly better ux.
New to Linux. Installed Ubuntu. Keep reloading youtube home page because recommendations suck. Want to to avoid shorts and other unneeded features by using Youtube solely through bash. Want to know if small quality of life changes can be made.
I'm wondering if it's possible to use the terminal to show a small number of videos from my home page, title with no thumbnail is enough, which shows dislike and like count, make it so that pressing not interested or don't recommend channel is a bit faster to click.
Sorry if this is a weird or absurd ask. I'm going cold turkey on AI overview, but want to see if there should be anything I need to know about starting a project like this.
https://redd.it/1x8aw96
@r_bash
Unset doesn't properly work in functions??
So this is super weird. When I run the following in a script (or manually in the terminal), it does exactly what you'd expect.
declare -A myassoc
myassoc[key]="Hello World"
unset myassoc
declare -p myassoc
echo "This should be empty: ${myassoc[@]}"
./dev2: line 9: declare: myassoc: not foundThis should be empty:myassoc is unset and therefore undeclaredfoo () {
declare -A myassoc
myassoc[key]="Hello World"
unset myassoc
declare -p myassoc
echo "This should be empty: ${myassoc[@]}"
}
foo
declare -- myassocThis should be empty:declare -p to test if variables exist regardless of their type and content.test is not a viable alternative, since it doesn't have the same behaviour for local myvar and declare myvar (vars without value return false, even if declared)bar () {
declare -A myassoc
myassoc[key]="Hello World"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
foo () {
unset myassoc
echo "In foo:"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
}
foo
echo "After foo:"
declare -gp myassoc
echo "This should be empty: ${myassoc[@]}"
}
bar
is there a way to improve a github release updater to pick the right asset name?
i made a script that actually works for most times to update brave browser, but for packages that change names its trivial. the idea is to place, update directory with a file with metadata that i can extract. here is the script :
updatePrograms() {
for dir in ~/Programs/*; do
#meta file structure
if [[ -f "$dir"/update/meta ]]; then
local metadata=$(cat "$dir"/update/meta)
local owner=$( echo "$metadata" | grep "Owner" | sed 's|Owner:||' )
local project=$(echo "$metadata" | grep "Project" | sed 's|Project:||')
local output=$(curl -fsS "https://api.github.com/repos/$owner/$project/releases/latest")
[[ -z "$output" ]] && { echo "no response for $project"; continue; }
local checkVersion=$(jq -r '.tag_name' <<< "$output")
echo "updatable Project : $project"
[[ "$checkVersion" = "null" ]] || [[ -z "$checkVersion" ]] && { echo "couldn't fetch version for $project"; continue; }
local currentVersion=$(echo "$metadata" | grep "Version" | sed 's|Version:||')
[[ "$checkVersion" = "$currentVersion" ]] && { echo "$project is up to date : $checkVersion"; continue; }
while true; do
read -p "$project is on $currentVersion, latest is $checkVersion; do you want to request the latest Version? [y/n]: " response
case "$response" in
[Yy])
echo "Updating.."
local name
name=$(echo "$metadata" | grep "AssetName" | sed 's|AssetName:||')
local url=$(jq -r --arg name "$name" '.assets[] | select(.name == $name) | .browser_download_url' <<< "$output")
if [[ -z "$url" ]] || [[ "$url" = "null" ]]; then
echo "couldn't find asset matching $name"
echo "you may need to change asset name version to $checkVersion"
break
fi
if curl -fL -o "$dir/update/$name" "$url" ; then
sed -i "s|Version:.*|Version:$checkVersion|" "$dir"/update/meta
else
echo "Downloading falied"
break
fi
break;;
[Nn])
echo "not Updating"
break;;
*)
echo "choose y or n";;
esac
done
fi
done
}
https://redd.it/1x66ycu
@r_bash
wiki how ?!
i installed termux and went to the wiki to learn it but for some reson all of the wikis [ arch wiki, official wiki, unofficial wiki, even \] stops with a prof u'r not a robot infenit bage and never work and even github won't upload the page not termux repo or any other repo , i know the problem is with me ; so do you know any other place to learn termux/terminal tools no matter if it's a wiki, a site, or even a book.
* i don't have a computer so don't tell me to use a one
https://redd.it/1x3w9zc
@r_bash