#shellscripting — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #shellscripting, aggregated by home.social.
-
Wrote a #shell function without using
lsinside of$( ), so my inner @mirabilos won't harass me. XD#slightly easier wireguard command function wg { local dir file profile profiledir= parm=${1:-} statustext #Find profile dir for dir in {,/usr/local}/etc/wireguard; do if [[ -d $dir ]]; then profiledir=$dir break fi done #Find config file if [[ -n $profiledir ]]; then for file in $profiledir/*.conf; do if [[ -e $file ]]; then profile=${file//*\/} profile=${profile/.conf} break fi done fi [[ -n $profile ]] || profile=proton statustext="wireguard profile $profile" case ${parm,,} in up|on) doas wg-quick up $profile;; down|off) doas wg-quick down $profile;; status) echo -en "$statustext _______\r" echo -en "$statustext " ifconfig |grep -q "^$profile:" && echo enabled || echo disabled;; *) warn "wg usage: wg up|down|status";; esac }Hmm, seems
${foo,,}for lower case conversion is #bash-only. I wonder if I should usetrinstead. -
Recursion usually scares me a bit, but it worked out nicely here:
#convert "cx"-style Esperanto notation to native accents (ĉ) function eaccent { if [[ ${1:-} ]]; then echo "$*" |eaccent else sed 's/cx/ĉ/g; s/gx/ĝ/g; s/hx/ĥ/g; s/jx/ĵ/g; s/sx/ŝ/g; s/ux/ŭ/g; s/C[xX]/Ĉ/g; s/G[xX]/Ĝ/g; s/H[xX]/Ĥ/g; s/J[xX]/Ĵ/g; s/S[xX]/Ŝ/g; s/U[xX]/Ŭ/g' fi }#bash #unix #shell #scripts #scripting #UnixShell #ShellScripting #Esperanto
-
🐢💤 Behold the revolutionary art of making Git diffs more complex than assembling IKEA furniture! All you need is #Delta, #fzf, a sprinkle of shell scripting, and the willingness to never see the sunlight again. Truly, the pinnacle of productivity hacks for those with too much time on their hands! 🙄🔧
https://nickjanetakis.com/blog/awesome-git-diffs-with-delta-fzf-and-a-little-shell-scripting #GitDiffs #ProductivityHacks #ShellScripting #TechHumor #HackerNews #ngated -
Improved Git Diffs with Delta, Fzf and a Little Shell Scripting
https://nickjanetakis.com/blog/awesome-git-diffs-with-delta-fzf-and-a-little-shell-scripting
#HackerNews #ImprovedGitDiffs #Delta #Fzf #ShellScripting #GitTips
-
TL;DW for the video:
Lock Fix: Detects/removes stale db.lck.
PGP Engine: Auto-fetches missing keys.
Wiki Deep-link: [w] opens the specific Wiki page for the error.
Smart Search: Finds package owners for missing binaries.
Repo: https://github.com/Rakosn1cek/mend (2/2)
-
Bash expansion explained for beginners. Learn brace, tilde, parameter, command, arithmetic, process, globbing, word splitting, and quote removal with practical examples.
Full guide here: https://ostechnix.com/bash-expansion-beginners-guide/
-
Here's a little puzzle for you. Can you figure out the purpose of this one-off shell script I just wrote?
If you post an answer put it behind a CW so you don't spoil it for others!
#programming #scripting #shellScript #shellScripting #Linux -
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. :/
-
Se vienen cositas próximamente en el blog y en el canal de YouTube 💪
Intentando aclarar algunos conceptos fundamentales de SSH para poder utilizarlo como un pro y no morir en el intento 🚀
¿Todavía no nos siguen? 👇
▶️ https://www.youtube.com/juncotic?sub_confirmation=1
¡Los esperamos para seguir aprendiendo juntos!
#gnu #linux #ssh #curso #firewall #iptables #nftables #wireshark #redes #tcpip #ciberseguridad #python #flask #shellscripting #juncotic
-
Shell Scripting in 20 Minutes – Crash Course | In One Video for Beginners | MPrashant
linux #mprashant #shellscripting #linuxtutorial Hello Dosto: In this video I have covered all the Shell Scripting Concept in just 1 ... source
-
Bash turns 38 today! Celebrate Bash's 38th birthday with 38 built-in features and essential tips. Learn keyboard shortcuts, parameter expansion, conditionals & more.
Full guide here: https://ostechnix.com/38-bash-tips-shell-features/
#Bash #Shell #Bash38 #Linux #Bashtips #Shelltips #Shellscripting #Linuxhowto #Linuxbasics #Linuxcommands
-
#PSA regarding #GNU #coreutils #sort's unexpected or at least non-intuïtive behaviour of its --unique (-u) option together with --numeric (-n) or --human (-h).
The output of piping something through
sort -nu
might not be equal to the output of piping the same thing through
sort -n | uniq
as it might miss some lines completely. 🤌
And it's NOT documented in the man page, just in the info page.
Related bug reports:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61696
https://bugs.debian.org/893524 -
A Lisp Interpreter for Shell Scripting
https://github.com/gue-ni/redstart
#HackerNews #Lisp #Interpreter #ShellScripting #Programming #GitHub #Redstart
-
🧹 Tidying Up After Myself: Automatically Deleting Old GitHub Issues
At some point, I had to admit it: I’ve turned GitHub Issues into a glorified chart gallery. Let me explain. Over on my amedee/ansible-servers repository, I have a workflow called workflow-metrics.yml, which runs after every pipeline. It uses yykamei/github-workflows-metrics to generate beautiful charts that show how long my CI pipeline takes to run. Those charts are then posted into a GitHub Issue—one per run. It’s neat. It's visual. It's entirely unnecessary to keep them […]https://amedee.be/%f0%9f%a7%b9-tidying-up-after-myself-automatically-deleting-old-github-issues/
-
Building off of what we learned at #Macstock2025 from @TheMikeBurke, I automated building new project folders using shell scripting and Keyboard Maestro. I had more fun doing that than starting my ScreenCastsONLINE project. Don't tell @leegarrett
https://www.podfeet.com/blog/2025/08/automation-project-folders/
-
Shell two-liner to watch your phone battery via KDE Connect while charging (or discharging):
alias kcbatt='qdbus6 org.kde.kdeconnect /modules/kdeconnect/devices/$(grep -Em1 "^\[[0-9a-f_]+\]" ~/.config/kdeconnect/trusted_devices |tr -dc 0-9a-f_)/battery org.kde.kdeconnect.device.battery.charge' ob=0; while b=$(kcbatt); do if ((ob!=b)); then date "+%H:%M $b%%"; ob="$b"; fi; sleep 5; done -
Shell two-liner to watch your phone battery via KDE Connect while charging (or discharging):
alias kcbatt='qdbus6 org.kde.kdeconnect /modules/kdeconnect/devices/$(grep -Em1 "^\[[0-9a-f_]+\]" ~/.config/kdeconnect/trusted_devices |tr -dc 0-9a-f_)/battery org.kde.kdeconnect.device.battery.charge' ob=0; while b=$(kcbatt); do if ((ob!=b)); then date "+%H:%M $b%%"; ob="$b"; fi; sleep 5; done -
Shell two-liner to watch your phone battery via KDE Connect while charging (or discharging):
alias kcbatt='qdbus6 org.kde.kdeconnect /modules/kdeconnect/devices/$(grep -Em1 "^\[[0-9a-f_]+\]" ~/.config/kdeconnect/trusted_devices |tr -dc 0-9a-f_)/battery org.kde.kdeconnect.device.battery.charge' ob=0; while b=$(kcbatt); do if ((ob!=b)); then date "+%H:%M $b%%"; ob="$b"; fi; sleep 5; done -
In the helpful shell functions department:
(Requires
bcto 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 } -
#Poll: Curious about people's attitudes towards shell scripting.
Two part question:
- Are you a DEVeloper (or working in a development-heavy role), OTHER-IT worker (such as a sysadmin, architect, anything in a non-development-heavy role), or NON-IT (accountant, doctor, whatever)
- Do you HATE shell scripting, are you INDIFferent towards (or ignorant of) shell scripting, or do you LOVE it?
#Unix #UnixShell #ShellScript #ShellScripting #POSIX #PosixShell #sh #bash #zsh #csh #tcsh #ksh #pdksh #oksh #mksh
-
New #blog post: Gathering Hashtags from the Fediverse
https://rldane.space/gathering-hashtags-from-the-fediverse.html
282 words (2233 counting the hashtags, but that's just silly)
cc: my wonderful #chorus: @joel @dm @sotolf @thedoctor @pixx @twizzay @orbitalmartian @adamsdesk @krafter @roguefoam @clayton @giantspacesquid
(I will happily add/remove you from the chorus upon request! :)
#rlDaneWriting #hashtags #bash #OneLiner #OneLiners #ShellScripting #Fediverse #API
-
I'm exploring ways to improve audio preprocessing for speech recognition for my [midi2hamlib](https://github.com/DO9RE/midi2hamlib) project. Do any of my followers have expertise with **SoX** or **speech recognition**? Specifically, I’m seeking advice on: 1️⃣ Best practices for audio preparation for speech recognition. 2️⃣ SoX command-line parameters that can optimize audio during recording or playback.
https://github.com/DO9RE/midi2hamlib/blob/main/tests/speech_menu.sh #SoX #SpeechRecognition #OpenSource #AudioProcessing #ShellScripting #Sphinx #PocketSphinx #Audio Retoot appreciated. -
🧱 The Three Tiers of the Linux Mind: A DeadSwitch Whisper for New Sysadmins #Linux #SysadminLife #OpenSource #CommandLine #DeadSwitch #LearnLinux #LinuxBasics #Cybersecurity #ShellScripting #TomITCafe #LinuxAdmin #TieredLearning #FOSS #DigitalResistance
-
Gotta say, I wish #bash had
local/ lexically-scoped functions, rather than having to rely on hacks like:function widget { function ___widget_parse { ... } ... unset ___widget_parse }Something like this (which does not currently work) would be lovely:
function widget { local function parse { ... } } -
If you're a #Linux person and using the command "ps" with options like "aux" instead of e.g. "-e" (i.e. options without leading "-"), you likely learned the #Unix #commandline on #BSD or maybe SunOS 🧔. (Or by someone who grew up with them. 🙂)
In other news: #TIL that (in either variant) the option "j" (e.g. as "ps ajx" or "ps -ej") also shows the PPID (parent PID, only with BSD style options), PGID (process group ID) und SID (session ID).
-
Pnut: A Self-Compiling C Transpiler Targeting Human-Readable POSIX Shell https://hackaday.com/2024/07/25/pnut-a-self-compiling-c-transpiler-targeting-human-readable-posix-shell/ #SoftwareDevelopment #shellscripting #transpiler
-
Pnut: A Self-Compiling C Transpiler Targeting Human-Readable POSIX Shell - Shell scripting is one of those skills that are absolutely invaluable on especiall... - https://hackaday.com/2024/07/25/pnut-a-self-compiling-c-transpiler-targeting-human-readable-posix-shell/ #softwaredevelopment #shellscripting #transpiler
-
Hey #AskFedi (#Linux / #UNIX / #BSD users in particular),
Does anyone have a preferred front-end to keepassxc-cli? I know there's a rofi interface shell script, but I honestly found it kind of clunky.
This is something that could be very easily and nicely shell scripted, and I wanted to ask if anyone knows of one out there already before I re-invented the wheel.
#Keepass #KeepassXC #ShellScripting #ShellScript #ShellScripts
-
I've recorded a screencast for my old bash script alltests — test runner for competitive programming. It runs an executable against set of static tests (sample inputs and outputs).
#asciinema #competitiveProgramming #bash #ShellScripting #utility #testing
-
While I've been waiting on packages to compile for ELFS I've been playing with xonsh in between builds.
Xonsh is a python-powered shell. I don't often use python, but have started growing a liking to it with xonsh.
It's got some pretty neat features and expands the capabilities of a traditional shell greatly.
What stood out to me the most is the fact that the PATH environment variable is an array and not a string. This is a quirk I've only ever seen in the rc shell from Plan 9. It's actually a really good quirk too! This feature actually makes it easier to script and manipulate the PATH variable in many ways.
While my demonstration is not particularly impressive I think it's kinda neat how python and shell are intertwined in such a nice way.
#python #shellscripting #shell #elfs #xonsh #linux #linuxengineer
-
Searching for "New York" followed by one or more capitalised words ... and massaging the resulting data a bit, results in the following list of New York institutions and/or aspects which receive mention at HN:
96 New York Times
51 New York City
25 New York
5 New York State
4 New York Public Library
3 New York City Subway
2 New York Harbor
2 New York Subway
2 New York Times Magazine
1 New York Attorney General
1 New York Charity
1 New York City Campus
1 New York Fed
1 New York Libraries
1 New York Magazine
1 New York Police
1 New York Post
1 New York Region
1 New York SenateNote that the 3rd entry, "New York" is itself ambiguous, and can refer to the city, state, or metro region, amongst others.
A handy reminder that language is itself ambiguous and provides a useful but not precise mechanism for transferring meaning or understanding (or sometimes ambiguity and confusion) between entities.
#HN #HackerNews #DataAnalysis #ShellScripting #GlobalCities #MediaAnalysis
-
HN Front Page / Global Cities Mentions
One question I've had about HN is how well or poorly it represents non-US (or even non-Silicon Valley) viewpoints and issues.
Pulling from the Globalization and World Cities Research Network list, the top 50 global cities names appearing in HN front-page titles:
1 191 San Francisco
2 164 London
3 117 Boston
4 86 Seattle
5 60 Tokyo
6 58 Paris
7 56 Chicago
8 56 Hong Kong
9 55 New York City
10 50 Berlin
11 50 Phoenix
12 45 Rome
13 40 Detroit
14 36 Singapore
15 31 Vancouver
16 30 Los Angeles
17 27 Austin
18 23 Beijing
19 20 Dubai
20 19 Shenzhen
21 19 Toronto
22 17 Amsterdam
23 16 Copenhagen
24 16 Houston
25 16 Moscow
26 15 Atlanta
27 14 Barcelona
28 14 Denver
29 13 Baltimore
30 13 San Jose
31 13 Stockholm
32 12 San Diego
33 12 Sydney
34 11 Cairo
35 10 Munich
36 10 Wuhan
37 9 Helsinki
38 9 Miami
39 9 Mumbai
40 9 Philadelphia
41 9 Shanghai
42 9 Vienna
43 8 Montreal
44 7 Beirut
45 7 Dublin
46 7 Istanbul
47 6 Bangalore
48 6 Dallas
49 6 Kansas City
50 6 Minneapolis(Best viewed in original on toot.cat.)
Note that some idiosyncrasies affect this, e.g., "New York City" appears rarely, whilst "New York" may refer to the city, state, any of several newspapers, universities, etc. "New York" appears 315 times in titles (mostly as "New York Times").
I've independently verified that, for example, "Ho Chi Minh City" doesn't appear, though "Ho Chi Minh" alone does:
https://news.ycombinator.com/item?id=15374051, on the 2017-9-30 front page: https://news.ycombinator.com/front?day=2017-09-30
So apply salt liberally.
Edits: tyops & speling.
#HN #HackerNews #DataAnalysis #ShellScripting #GlobalCities #MediaAnalysis
-
I wrote a script to resolve lists of domains from stdin, since dnsx and the like does not like my VPN settings.
(feedback appreciated - Bash noob)
https://github.com/n0kovo/dnsplz
#BugBounty #DNS #DnsRecon #Bash #ShellScript #ShellScripting #BashScript #Enumeration #DnsEnumeration #InfoSec
-
Bash Scripting - Printf Command Explained With Examples #Printf #BashScripting #Bash #ShellScripting #Commandline #CLI #Linux #Linuxbasics #Linuxcommands #Bashtutorial #Linuxhowto
https://ostechnix.com/bash-printf-command/ -
Bash Scripting - While & Until Loop Explained With Examples #BashLoops #WhileLoop #UntilLoop #BashScripting #ShellScripting #Bash #Linux #Linuxhowto
https://ostechnix.com/bash-while-until-loop-shell-scripting/ -
Bash Heredoc Tutorial For beginners #Heredoc #HereDocuments #Bash #BashRedirection #Shell #ShellScripting #Script #Linux #Linuxhowto #Bashtips #Commandline #CLI
https://ostechnix.com/bash-heredoc-tutorial/ -
Linux Fu: Leaning Down with exec - Shell scripting is handy and with a shell like bash it is very capable, too. However, shell scriptin... more: https://hackaday.com/2019/12/30/linux-fu-leaning-down-with-exec/ #hackadaycolumns #shellscripting #linuxhacks #linuxfu #skills #linux #bash #exec