r_bash – Telegram
Using cut to get versions

Suppose I have two different styles of version numbers:
- 3.5.2
- 2.45

What is the best way to use cut to support both of those. I'd like to pull these groups:

- 3
- 3.5

- 2
- 2.4

I saw that cut has a delemiter, but I don't see where it can be instructed to just ignore a character such as the period, and only count from the beginning, to however many characters back the two numbers are.

As I sit here messing with cut, I can get it to work for one style of version, but not the other.

https://redd.it/1lbtgyg
@r_bash
tzview - Display in local time lunchtime in other timezones.

I wrote a shell noscript that displays the current time in various
timezones. It is useful for organizing meetings with people in different
timezones, do not create a meeting at lunchtime to someone in Australia.

https://github.com/harkaitz/sh-tzview

https://redd.it/1ldj1fs
@r_bash
Rewriting a utility function noscripts library for Linux

I've made a simple utility functions noscripts librarytsilvs.bashlib for Bash.

Daily-driving Bazzite, I've designed it to simplify some interactions with Fedora Silverblue family of distros, especially rpm-ostree. But it might come in handy for active ADB and Git users too.

I'd like to reduce the amount of repetative code. If you have some time, review my code please. Re-implementation suggestions are welcome too.

tsilvs.bashlib: https://github.com/tsilvs/bashlib

https://redd.it/1ldnpge
@r_bash
Bash-based command-line tool to compare two folders and create html reports
https://redd.it/1le397d
@r_bash
Script to see how much space each incremental backup uses - may be useful

I've a noscript that uses rsync to create incremental backups, and I wanted have a list of the directories and the amount of space each backup is using. Here it is:

https://github.com/funkytwig/funkierbackup/blob/main/dir\_usage.bash

The output looks something like this:

/home/ben/test_backup/2025/06/15/23_D: 384KB
/home/ben/test_backup/2025/06/16/14_H: 128KB
/home/ben/test_backup/2025/06/16/15_H: 132KB
/home/ben/test_backup/2025/06/16/16_H: 120KB
/home/ben/test_backup/2025/06/16/17_H: 128KB
/home/ben/test_backup/2025/06/16/18_H: 120KB
/home/ben/test_backup/2025/06/16/19_H: 120KB
/home/ben/test_backup/2025/06/16/20_H: 120KB
/home/ben/test_backup/2025/06/16/21_H: 136KB
/home/ben/test_backup/2025/06/16/22_H: 128KB
/home/ben/test_backup/2025/06/16/23_D: 124KB
/home/ben/test_backup/2025/06/17/00_H: 120KB
/home/ben/test_backup/2025/06/17/01_H: 120KB
/home/ben/test_backup/2025/06/17/02_H: 120KB
/home/ben/test_backup/2025/06/17/03_H: 120KB
/home/ben/test_backup/2025/06/17/04_H: 120KB
/home/ben/test_backup/2025/06/17/05_H: 120KB
/home/ben/test_backup/2025/06/17/06_H: 120KB
/home/ben/test_backup/2025/06/17/07_H: 120KB
/home/ben/test_backup/2025/06/17/08_H: 120KB
/home/ben/test_backup/2025/06/17/09_H: 120KB
/home/ben/test_backup/2025/06/17/10_H: 120KB
/home/ben/test_backup/2025/06/17/11_H: 120KB
/home/ben/test_backup/2025/06/17/12_H: 120KB
/home/ben/test_backup/2025/06/17/13_H: 120KB
/home/ben/test_backup/2025/06/17/14_H: 184KB

https://redd.it/1ldns6p
@r_bash
Found a Bash-based uptime monitor… it’s just curl in a while loop

Discovered our “external uptime check” was literally -

while true; do
curl $SERVICE_URL
sleep 60
done


Running on a Raspberry Pi under someone’s desk, with no logging, no alerting, and no supervision.

Dropped it into Blackbox hoping for some clever logic. Nope. Just curl.

Anyone else stumbled across “creative” Bash in prod like this?

https://redd.it/1lejy8s
@r_bash
Go-like programming language that transpiles down to Batch or Bash

Hey Bash enthusiasts!

A while ago I wanted to get a bit into compiler/transpiler building and first I couldn't really think about something useful. So I thought, which language is super complicated to use even for the most basic tasks? And than it hit me...Batch! So that's what my small Go-like language became, a Batch transpiler, but it can also transpile to Bash (that's why I also posted it here).

Give it a try, I would like to hear your thoughts on it :)

https://github.com/monstermichl/TypeShell

https://redd.it/1lev9bi
@r_bash
I was reading this bash guide on GitHub ajd found this:
https://redd.it/1lf2hru
@r_bash
Help understanding ambiguous redirection behavior in bash

I'm working on building my own small shell that mimics bash behavior, and I'm trying to understand when and why "ambiguous redirect" errors happen.

Consider this situation:

export a=" " // just a bunch of spaces

Now these two examples behave differently:

ok$a"hhhhh"$.... // this is NOT ambiguous -works fine

ok$a"hhhhh"$USER // this IS ambiguous

I'm confused — why does using $a (which is just spaces) before a variable like $USER lead to an ambiguous redirect, but using it before a string of characters like ... doesn’t?

Also, I noticed that in some cases, $a splits the word:

ok$a"hhh"$USER # gets split due to spaces in $a

But in this case, it doesn’t seem to:

ok hhhhh$... # stays as one word?

Can someone explain when $a (or any variable with spaces) causes splitting, and how this leads to ambiguous redirection errors?

Thanks in advance!

https://redd.it/1lf6ccw
@r_bash
Getting parent dir of file without path in one step in pure bash?

Is there an easy way to get the parent dir of a file without the path in pure bash? Or, in other words, get the substring of a variable between the last and next-to-last slash?

I know of

path='/path/to/pardir/file'
dirpath="${path%/}"
pardir="${dirpath##
/}"
echo "$pardir"
pardir

With awk:

$ awk -F '/' '{sub(/\.^.+$/, "", $NF); print $(NF-1)}' <<< "$s"
$ pardir

and there's also expr match, although I'm not good with regexes. Not to mention dirname and basename.

Is there an easy, one-step incantation with pure bash so I can get this substring between the two last slashes?

https://redd.it/1li8ylt
@r_bash
Need help syntax error
https://redd.it/1liolod
@r_bash
bash2json - fully bash-written JSON parser

so, firstly it was created as a simple parser function for my another project, but i kinda wanted to make full JSON support in vanilla bash including arrays support, so it's fully written using bash substitution and builtins

i'd be happy to listen to any critics/suggestions
https://github.com/Tirito6626/bash2json

https://redd.it/1lkhk4i
@r_bash
fz - Pipe commands to FZF

Hello folks,

Last week, I was showing one of my functions sourced in .bashrc and .zshrc to one of my colleagues at work. He liked, then I decided to make it a Bash noscript on a GitHub repo, so more people can use it. Thus, I present fz - Pipe commands to FZF!

Before I share the repo with other colleagues, can you please review my code and give some comments? As a non-native English speaker, I will also appreciate if you double-check the documentation.

The purpose of the noscript is facilitating the usage of FZF with some common commands: man, ssh and kill. If you have some useful functions or alias that could be added to the noscript, please, don't hesitate to share.

Last, but not least, pull requests are welcome!

Thanks a lot! Hope you like it!

https://redd.it/1llnqc4
@r_bash