Am I the only one that never, ever uses getopt/getops in shell scripts?
Just writing your own argument parser seems so much easier to do. :/
Am I the only one that never, ever uses getopt/getops in shell scripts?
Just writing your own argument parser seems so much easier to do. :/
Haack's Networking - Informal Hacking Session #03
1) Today's agenda is rsnapshot script/stack migration from backup 8700 machine to 7920, i.e., to backup the backup.
2) Write the article for the bind9 authoritative DNS server.
3) If time and/or stamina permits, we will work on this month's timbre post where I cover my month's listening history.
Live Steam w/ Chat: https://content.haacksnetworking.org/w/byjvKm4LXLLn7q4ngYaG8f
#livestream #live #gnulinux #sysadmin #floss #freesoftware #rsync #rsnapshot #shellscripts
The more I adapt #chezmoi for my setup (will still take ages!), the more I like this tool. 👍
All of my special requirements could be addressed so far in a clean/reasonable way. And I do have plenty weird requirements. 🤓
It's made for #dotfile management but it is more versatile than that. For example, I'll manage most (if not all) of my personal #shellscripts with that as well.
Had a blog post do really well this month, unexpectedly gave a talk at @longhorn, learned some lessons about tech and US fascism, and clicked some more links. My notes from October 2025: https://evanhahn.com/notes-from-october-2025/
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
Published a big list of scripts I've written over the years: "copy" and "pasta" for working with the clipboard, "getsong" to download music, "murder" for stopping processes, and dozens more: https://evanhahn.com/scripts-i-wrote-that-i-use-all-the-time/
Mostly, when I'm writing #ShellScripts, I use #BASH. However, sometimes, a script that works just fine on my desktop will fail when run from within a #Docker #container. So, I'll use #podman to fire up the selected container to debug my script within (like so):
podman run -it --entrypoint /bin/sh docker.io/python:3.12-alpineUsually, the problem with my script is that it wants BASH but, particularly Alpine-based containers, only have #ASH. So, I'll have to re-work my script to be ASH-compatible (which usually means a script that's a lot less terse).Prevent overlapping cron jobs using `flock`
https://tech.mrleong.net/prevent-concurrent-cron-jobs-using-flock
In the helpful shell functions department:
(Requires bc to be installed)
load() {
local load=$(uptime |sed -E "s/^.*load averages?: //; s/,.*$//")
local uname="$(uname)"
local cpus
if [[ $1 == -q ]]; then
echo "$load"
elif [[ $1 == -i ]]; then
echo "$load + 0.5" |bc -l |cut -f1 -d.
else
case "$uname" in
Linux) cpus=$(grep -c ^processor /proc/cpuinfo);;
*BSD) cpus=$(sysctl hw.ncpu |tr -dc "0-9\n");;
*) warn "load(): assuming 1 cpu, don't know how to get the number in \"$uname\""
cpus=1;;
esac
local loadPerCPU=$(echo "scale=3; $load / $cpus" |bc -l |sed 's/^\./0./')
echo "$load ($loadPerCPU per processor ($cpus))"
fi
}
I am so sorry if it failed to excite you! Nope, not your fault. :)
PS: Especially if you are a "Skimmer" ......
#linuxadmin #linux #tools #opensource #emacs #vim #git #zathura #firefox #nyxt #vimb #cli #commandline #shell #st #suckless #terminal #patch #solarized #gruvbox #cmus #mpv #ffmpeg #btop #shellscripts #bash