#bash
Avis aux #Mastopotes , si à partir de 15h30 environ, vous voyez passer des questions #bash ; #python ou #PowerShell ; dont la réponse vous est évidente, n'hésitez pas à répondre (enfin, si vous comprenez l'énoncé, c'est souvent ça le problème aussi)
Need to locally rerun a command every time it finishes? This simple snippet will do just that! #bash #programming

Just noticed that infinisil spent a little time on github.com/abathur/resholve in The Nix Hour a few weeks back.
https://youtu.be/9l8vx0dcl6k?t=1418
Also realized how helpful it is to be able to watch someone else try to grok your docs in real time :)
This works really well, since you can just use #bash's or (`||`) operator when something fails like so:
false "I'm guaranteed to fail" || die "Yup, I failed!"
but it has the side-effect of needing to explicitly set the return code prior to calling `die` if you want to control it instead of using the rc of the prior command. That ends up being awkward.
🧵
I used to always use my own `die` function in all of my #bash scripts to spit out a message and exit (inspired by perl, I believe?). It would look like:
die "I'm dying for reasons!"
and the script would stop and possibly have an error code as a result.
The first thing the function would do was save the result code from the prior command (`$?`) and use that as its return code, and also to control whether the message appeared on stderr (rc > 0) or stdout (rc == 0).
🧵
I've set up a simple bash script to update a DNS record for my domain with CloudFlare whenever my home IP address changes, this effectively using CloudFlare as Dynamic DNS service:
#bash 1-Zeiler. Linux mit grafischer Oberfläche (KDE, Gnome).
#Musik stummschalten -einschalten . "clementine" kann gegen "vlc" oder andere Player getauscht werden
dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.clementine /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Unable to List Contents or Create Files in /var/tmp Folder from PHP Executed Bash Script #bash
I'm coding in #bash so #nowplaying - https://youtu.be/v-mmjg5-Qi4
Allez, ça faisait longtemps que je n'avais pas écrit sur mon blog...
https://www.metal3d.org/blog/2023/bien-configurer-son-terminal-bash/
@GrahamDowns i do not think a #Powershell user will take offense. PowerShell is not a pure shell though, it is an object oriented scripting (programming) language with a shell.
i am pretty sure most ps users use #bash (or another unix-shell) as a default shell on linux.
#Bash kann rechnen :
A="22.53";B="8";C="-6"
## mit ganzen Zahlen
echo $(( B+C ))
## mit rationalen Zahlen
echo "$A/$B" | bc -l
My word, can Microsoft not do anything right? Compared to #bash, PowerShell is a hideously verbose, ridiculously complex shell, and I can't imagine why anyone would want to use it.
In my opinion, of course. If you're a #PowerShell fan, I apologise, and I meant no offense. :)
Linux-Terminal-Basics 12: Schleifen mit for, while, until | Tutonaut.de
https://www.tutonaut.de/linux-terminal-basics-12-schleifen-mit-for-while-until/ #Linux #Terminal #Bash #Schleifen
Script en bash que comprueba si hay internet y ejecuta unos programas #Linux #Scripts #Bash https://myblog.clonbg.es/#/script-autostart https://clonbg.es


Grabar una iso en un Usb desde la terminal con dd #Linux #Terminal #Bash https://myblog.clonbg.es/#/grabar-dd https://clonbg.es

#Bash kann auch Arrays. Nativ ist das Array 1-dimensional
Sehr einfaches Beispiel: schreibe 3 Werte in eine Datei,. lese dann zeilenweise in ein Array und zeige den Inhalt an.
echo "a
b
c" >lolo.txt
readarray x <<< $(cat lolo.txt)
echo ${x[@]}
So ... I'm playing with a report showing how often F500 companies are mentioned in HN submission titles.
As I've noted, most of my scripting is in awk (gawk), and it's ... usually pretty good.
I'm toying with a couple of loops where I read all 178k titles, and all 500 company names, into arrays, then check to see if the one appears in the other.
The first iteration of that was based on the index() function, which is a simple string match. Problem is that there are substring matches, for example "Lear" (the company) will match on "Learn", "Learning", etc., and so is strongly overrepresented.
So I swapped in match(), which is a regular-expression match, and added \W as word-boundaries.
The index-based search ran in about 20 seconds. That's a brief wait, but doable.
The match (regex) based search ... just finished as I'm writing this. 13 minutes 40 seconds.
Regexes are useful, but can be awfully slow.
Which means that my first go at this --- still using gawk but having it generate grep searches and printing the match count only ... is much faster whilst being accurate. That runs in just under a minute here. I'd looked for another solution as awk is "dumb" re the actually output: it doesn't read or capture the actual counts, so I'll either have to tweak that program or feed its output to an additional parser. Neither of which is a big deal, mind.
Oh, and Apple seems to be the most-mentioned company, though the F500 list omits Google (or YouTube, or Android), listing only Alphabet, which probably results in a severe undercount.
Top 10 using the F100 list:
1 Apple: 2447
2 Microsoft: 1517
3 Amazon: 1457
4 Intel: 554
5 Tesla: 404
6 Netflix: 322
7 IBM: 309
8 Adobe: 180
9 Oracle: 167
10 AT&T: 143
Add to those:
$ egrep -wc '(Google|Alphabet|You[Tt]ube|Android)' hn-titles
7163
egrep -wc '(Apple|iPhone|iPad|iPod|Mac[Bb]ook)' hn-titles
3656
egrep -wc '(Facebook|Instagram)' hn-titles
2512
Note I didn't even try "Meta", though let's take a quick look ... yeah, that's a mess.
Up until 2021-10-28, "Meta" is a concept, with 33 entries. That was the day Facebook announced its name change. 82 total matches (so low overall compared to the earlier numbers above), 49 post-announcement, of which two are not related to Facebook a/k/a Meta. Several of the titles mention both FB & Meta ... looks like that's four of 'em.
So "Meta" boosts FB's count by 45.
There are another 296 mentions of Steve Jobs and Tim Cook which don't also include "Apple".
And "Alphabet" has 54 matches, six of which don't relate to the company.
Of the MFAANG companies:
Google: 5796
Apple: 2447
Facebook: 2371
Microsoft: 1517
Amazon: 1457
Netflix: 322
(Based on grep.)
Using #zsh instead of #bash challenges me in unexpected ways. It forces me to explore intricacies of both shells to make it work how I like across machines.
I don't have a strong opinion about which I prefer, just a fun learning experience about things I took as given. Gives me a glimpse into why some folks adhere to #ksh
I use it as shell only, not for scripting.
To require an argument in a #bash function use `${arg:?error_msg}`:
func() {
local arg="${1:?"Argument required"}"
echo "${arg}"
}
Winexe error NT_STATUS_LOGON_FAILURE executing script from Linux to Windows Server 2012 #networking #server #bash #scripts #samba
Alle docker images updaten. Dieser 1- Liner für #Bash ist nicht von mir, aber ich benutze ihn regelmäßig,
docker images | grep -v ^REPO | sed 's/ \+/:/g' | cut -d: -f1,2 | xargs -L1 docker pull
How to put sudo operations (apt-get) on a shell script? #commandline #apt #bash #scripts #sudo
Odd filesystem behavior lately #bash #filesystem
Simple Linux Kernel Picker
I run Fedora in my home-lab as the base OS for my server. It works well for me but I do occasionally run into an issue where Fedora will make a new kernel available before the ZFS project has support for it. {...}
https://topslakr.com/2023/06/simple-linux-kernel-picker/
#BASH #Computers #GitHub #Linux #BASHScript #Fedora #GitHub #Kernel #Linux #ZFS
export path to $PATH via shell script #bash #environmentvariables #bashrc
~/.bashrc displays entries depending on how it is called #bash #environmentvariables #bashrc
Y a des pros d'API / Python / PeerTube / Bash ici ?
J'ai un problème pour transformer un programme #bash en #python que j'ai posté ici : https://framacolibri.org/t/obtenir-un-token-pour-lapi-en-python/17968
Merci 🙏
Uhh.. when I have a function in Bash (let's call it fun() because it isn't), and call it like
$ fun > /dev/null
then - as expected - global variables modified in it are changed in the outer scope afterwards.
If I call it like
$ fun | tee /dev/null
they global variable with its current value is available in the function, but after the call it has the old value from before the call?!
#Bash, you drunk?

"Mit der Bash-Skriptsprache in Linux kann man Speicherplatz durch das automatische Löschen von alten Dateien sparen. Zum Beispiel: find /path/to/files* -mtime +7 -exec rm {} \; #Linux #Bash #OpenSourceTipps"
Grabar una iso en un Usb desde la terminal con dd #Linux #Terminal #Bash https://myblog.clonbg.es/#/grabar-dd https://clonbg.es


My #achievements at age 15:
- Published an app on #Flathub, and more are to follow
- #GNOME Foundation Member
- Project member of two other apps, Upscaler and Cavalier
- Lots of #contributions to lots of other apps
- I know #Python and #Bash really well, am getting good at #Rust
- Got to know many cool #programmers and #OpenSource enthusiasts!
I'm quite proud of myself, to be honest!
The big #bash is taking place Oct. 22 at the In-N-Out Burger Pomona #Dragstrip.
https://www.foxla.com/news/in-n-out-burger-anniversary-festival-tickets-pomona-dragstrip
Finally, my first concrete foray in middleware audio for video games. A post about how I speed up the process of creating folders in a filesystem that mirrors a large number of Switches in a Wwise project.
Done on macOS with GNU bash.
https://minutestomidnight.co.uk/blog/create-local-folders-matching-a-wwise-switch-group-content/
Is there any #bash #utility which can be used to wrap and modify output from other commands?
My specific desire/use-case is to add colors to part of the output from `terraform apply` - I'd like to make any "Creating..." strings be yellow, and any "Creation complete after *" strings be in green.
Perhaps some #terraform #plugin exists?
@benjamineskola agreed. Trying really hard not to plug my #bash post, but I argue there that for practical definitions, #bash's portability hits the sweet spot if we use a subset of it (which is still broader than #sh).
@htothedip assuming you understood the person correctly, I suggest remembering who suggested that and never ever listen to them again.
Reason: #zsh scripts are *not portable at all*. #Python is at least somewhat portable because most of computers have python in their system dependencies.
#Zsh is fringe (as #fish is) and a lot of the magic of #zsh is replicated with #fzf.
Anyhow... I find that the optimum portability for me is writing stuff in #bash.
@sataa @otfrom I'd really live to use #fish more, but sadly I'm stuck on #bash since "installing another shell" is seen as a "security risk" only topped to "installing a compiler" and "chown 777 everything"...
And currently all tools I've to use on #Ubuntu, #RHEL, #SLES / #SLED & Co. are depenent on #bash.
@otfrom I do avoid them as much as possible.
Sadly, unless all distros purge the RMS-tainted GNU trash, I'm kinda forced to use it in ~ some capacity ~ due to the socioeconomic requirement to do #WageWork.
Personally, I avoid using them at all costs whereever possible, but sadly all relevant distros still use #bash instead of #fish and #ChimeraLinux isn't something I can introduce or shove into production...
50 #Bash Script Examples to Kickstart Your Learning :bash:
https://linuxopsys.com/topics/bash-script-examples
@dolari also #Windows is #bloated #Govware, inherently insecure and.doesn't even come with the most basic tool out of the box, like a useable #shell (neither #fish nor #zsh nor #bash!)[#Linux Subsystem for Windows doesn't count as it's not default preinstalled and integrated] nor trivial things like a #PackageManager or working #updates & #upgrades.
Shit that Linux does for 15+ years now...
Oh wow, TIL: When you do input redirection from a file in #bash, e.g.
python whatever.py < foo.csv
the running command can actually stat() the stdin file descriptor and get the size of the input file! I would’ve expected that it’s more like “well, it’s your stdin, you can’t get the size for that, it’s a stream”.
And, to be fair, if you don’t directly associate the file to the command, it breaks. For example,
cat < foo.csv | python whatever.py
won’t supply a size.
The sx layer in the GeoPKG uses the centre-line track-model overlay on OpenStreetMap #OSM rail data based on minimum point to track distance
The ox uses only OSM data for track and meta-data tags
TIPLOC and STANOX locations are matched using the #NetworkRail OpenDataFeeds #CORPUS dataset
Code is developed in #python using #Geopandas #networkx #osmnx #Momepy #Shapely and #bash shell
@daviwil how to set it up with #Emacs to get completion and lookups and instant documentation. For system scripting languages like elisp or even #bash there's so much content, both built-in and online, on how to build out. Yet from what I've experienced trying to jump into guix, guile code is a lot more "paste it in, if it breaks go back" than those which is unfortunate. Or is there a great tutorial I've missed?
Una de las cosas que más extraño de la red del pajarito son los bots, así que decidí (re)implementar mi favorito.
En un par de horas hice mi primer #bot de #Mastodon con scripts de #bash usando #curl en un servidor #Linux
@volcanes_cr_bot descarga imágenes del #volcanes del #Ovsicori #UNA por ahora solo publica al #Volcán #Poás
El código fuente lo publiqué con una licencia libre #gpl en Github por si alguien quiere implementar sus propios bots rápidamente y sin dolor.
@hazelweakly I know and I really would love to see that.
Basically porting a lot of advantages from #snap, #fish and #PyCharm to #bash...
Pretty shure this would require either a derivative language [i.e. "enhanced bash" / "ebash"] or require some preprocessor approach like #Blitz [#BASIC] and #Sass [#TypeScript]...
this week I helped organize the #ProgrammingByStealth student organization repository.
https://www.podfeet.com/blog/category/ccatp/https://www.podfeet.com/blog/category/ccatp/
#bash #Programming
Linux Fu: Supercharge Bash History - Having a history of shell commands is a great idea. It is, of course, enormously h... - https://hackaday.com/2023/05/05/linux-fu-supercharge-bash-history/ #linuxhacks #featured #linux #bash
Hey, I go by the penname DROSOPHILIAC—you call me Dros or Drossy if you want. I'm 24 and am #nonbinary.
I'm a busy #bioinformatics student. I code in #Python but intend on learning #R and #Bash.
I also do electronic #musicproduction in #Reaper. I intend to finish my first album sometime this year. We'll see if I can throw some music up on the internet anytime soon.
Beyond that, I write #poetry and make #digitalart for fun and self-expression. I'm #autistic and generally quite #neurodivergent.
Thanks for reading.
New post: Improving my interactive #jq workflow with ijq, #bash and #tmux.
I'm a big fan of ijq and how it allows me to explore #JSON data interactively with jq expressions. With a small script I have improved my workflow by being able to capture the jq expression from ijq and use it easily on the command line.
Share & enjoy!
Let's settle this once and for all.
#programming #gamedev #webdev #cpp #java #javascript #python #c #csharp #html #typescript #kotlin #go #golang #rust #rustlang #clang #texteditor #ide #coding #code #poll #automation #shell #bash #powershell #basic
@AlgoCompSynth @h “Readable” implies what the reader already knows how to read.
Your reply is to a post where I specifically said the point was about converting from #Bash.
If you don’t know how to read a #shell script you definitely don’t know how to convert it to another #programming language. You’ll be doubly handicapped if the new language is nothing like the old.
@h Oh, I don’t deny it’s useful. And you’ll never catch me saying it’s bad to stick with what you know if it gets the job done—that’s one reason I continue to use #Perl.
My main point was that it’s less work converting #Bash to Perl than to #JavaScript.
The “kids want JavaScript everywhere” was admittedly a little snark directed at the “continuous amnesia” of prior art (not unique to #JS developers but their sheer number means it’s *really* prevalent) as described here: https://www.ufried.com/blog/continuous_amnesia_issue/
This is hilarious. A #Google engineer invented #zx, a utility to make command line scripting easier with #NodeJS, because at a certain point #Bash scripts get too complicated and you need a Real #Programming Language.
This is exactly #Perl's use case from thirty-six years ago. But the kids want #JavaScript everywhere and would rather it take more work to convert their ascended #shell scripts to a vastly different syntax.
Backing up to a USB stick automatically via udev on #Debian #Linux.
Building on yesterday's discussion about automatic USB backups, here's a #BlogPost setting out how I have done it.
tl;dr:
- a udev rule runs when a specific USB disk is detected
- it runs a script calling "at", scheduling a backup in one minute
- the disk mounts automatically and LUKS decrypts
- in one minute, the backup runs
- I get some desktop alerts as to status
- I remove the disk
https://neilzone.co.uk/2023/04/backing-up-to-a-usb-stick-automatically-via-udev
I just updated, improved and translated my #bash script to set the wallpaper to a current image of Earth centred in a city with the actual light and shadow on it and some info. Using info from @wikipedia #fourmilab.ch and @openmeteo https://gitlab.com/antoniodelgado/earth_wallpaper/
Index of Pat’s pinned toots:
#introduction
https://qoto.org/@Pat/109306457253697111
Guide to Content Warnings
https://qoto.org/@Pat/109321533928955163
#BASH #strings
y=${x##*pid=}; echo ${y%%,*}
https://qoto.org/@Pat/107817893151595161
- - -
#covid19
A properly worn respirator stops all variants of the COVID-19 virus -- past, present and future...
https://qoto.org/@Pat/107364049546018993
- - -
#race #film
A pseudorandomly selected list of ten films to critique regarding how they treat black actors/characters
https://qoto.org/@Pat/107140410303609143
- - -
A list of #abbreviations
https://qoto.org/@Pat/107642967957592172
- - -
#awareness
What's wrong with this picture?
https://qoto.org/@Pat/107111545496373988
Want(not need) help/w optimizing rando langs I've written working calculator gui cloud app servers,only rely on stdin stdout in #ada #awk #bash #basic #C #cplus #COBOL #CLisp #Forth #FORTRAN #Go #java #Lisp (mine) #Lua #Pascal #Perl #Python #R #Rust #Ruby #SED These all work and talk to the thin client @ other end of a socket just fine, but lots are my first ever app in language. LMK if you have smaller https://bitbucket.org/timcdoc/antibrowser/src/master/ $lang calc under that. also looking for destupify stdio|powershell
@jaredwhite @cappiello @vanilla @bridgetown Oh, I know. I'd prefer to stick with back-end development (.NET, C#, ASP.NET, SQL Server) because I'm familiar with it and I only got into coding because it pays better than cleaning toilets, but I keep landing in projects that want full-stack so I must perforce adapt.
On my personal website, though, my stack is #make, #bash, #sed, #awk., #pandoc, #htmlXmlUtils, and #ImageMagick. Deployment is #rsync over #ssh. :)
Automating actions in Nautilus (GNOME's file manager) with scripts:
A quick write-up of my successful attempt to get a context menu script in Nautilus, to copy a file and rename it by prepending today's date.
Simple, and it will save me a lot of irritation.
#BlogPost: https://neilzone.co.uk/2023/04/automating-actions-in-nautilus-gnomes-file-manager-with-scripts
Anyone use any nifty tools for long-term archival of local #bash history? I generally take notes as I go but every once in a while I find myself wishing I could go further back in history to follow my complete line of thought. 🙂
How about some digital Spring Cleaning this time of the year. Always a good idea to review your digital files and clean out your digital life as well. Something a data hoarder is not good at...
https://claytonerrington.com/blog/spring-cleaning/
#100DaysToOffload post 26!
100X your #10Xdeveloper with this handy #OpenAI API #bash scripts #AI #ChatGPT #LLM https://kadekillary.work/posts/1000x-eng/