File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
File this under #shell #functions I should have written years ago:
function grepc {
#Do a grep -c, but skipping files with no results
grep -c "$@" |grep -v ':0$'
}
P.S., the body of the parent #toot was created by a simple #shell #function:
function apod {
#Today's NASA Astronomy Picture of the Day info-fetcher
curl -sL 'https://apod.nasa.gov/apod/archivepix.html' \
|grep -m1 "[0-9][0-9]:" \
|sed 's/^/Date: /;
s|: *<a href="|\nURL: https://apod.nasa.gov/apod/|;
s/">/\nTitle: /; s/<.*$//'
echo
echo "#NASA #Astronomy #PictureOfTheDay"
}
#bash #ksh #mksh #shellScripting #unix #UnixShell #WebScraping #Scraping #HTML
Since people are going nuts online about how perfect February 2026 is... here you go:
~ $ cal feb 2026
February 2026
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
~ $ for x in {1900..2050}; do cal feb $x |grep -q "^ 1 " && echo $x; done
1903
1914
1920
1925
1931
1942
1948
1953
1959
1970
1976
1981
1987
1998
2004
2009
2015
2026
2032
2037
2043
Einleitung in die Linux Shell
Warum du die Shell kennen solltest Bevor Icons und Fenster die Bildschirme der Computer erobert haben, hast du Befehle eingegeben, um mit den meisten Computern zu interagieren. Auf UNIX-Systemen, von denen Linux abstammt, war das Programm, das diese Befehle interpretiert und verwaltet hat, die Shell. Du kannst dich darauf verlassen, dass die Shell unabhängig von deiner Linux-Distribution immer verfügbar ist. Sie ermöglicht dir, ausführbare Skriptdateien zu erstellen, Programme […]Rule/Yule 30 cellular automaton with a "band-pass" filter every few iterations. Done in the Bash shell using bitwise math, so each row/state is a single number of 63 bits.
#cellularautomata #cellularautomaton #rule30 #bitwiseoperators #textmode #textmodeart #oldskool #retrocomputing #unixshell #shellprogramming #xterm #joulu6 #xmastree #algorithmicart #algorist #mathart #laskutaide #ittaide #kuavataide #iterati
Making a Scheme script on unix
Did you know that UNIX scripts can be made without a shebang line? What happens then? The operating system, when it sees file marked as executable, tries to run it. If it is not executable however it will then try to run it as a shell script.[1] Why is that relevant to scheme?
#scheme #programming #dev #unix #unixshell
https://retropikzel.neocities.org/blog/2025-11-06%20-%20Making%20a%20Scheme%20script%20on%20unix.html
Umm, why didn't I do this... years ago??
~ $ wc pinglog.txt
387290 1549160 11618700 pinglog.txt
~ $ type commaify
commaify is a function
commaify ()
{
local expr='s/([0-9])([0-9]{3}\>)/\1,\2/g';
sed -E "$expr; $expr; $expr; $expr; $expr; $expr; $expr; $expr; $expr; $expr"
}
~ $ wc pinglog.txt |commaify
387,290 1,549,160 11,618,700 pinglog.txt
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
}
#Poll: Curious about people's attitudes towards shell scripting.
Two part question:
#Unix #UnixShell #ShellScript #ShellScripting #POSIX #PosixShell #sh #bash #zsh #csh #tcsh #ksh #pdksh #oksh #mksh
I experimented with not having persistent shell history, after @simontatham blogged about it.
Good:
- higher threshold for writing long complicated commands
- lower threshold for writing shell scripts instead
Bad:
- writing shell scripts
I've since started experimenting with the Fish shell, and it brings a whole different level to the shell history game. So far I like it.
I've probably tooted about this before, but I don't know why this isn't standard.
It's just so obvious, at least to me. ;)
~ $ type mcd
mcd is a function
mcd ()
{
[[ -n $1 ]] && mkdir "$1" && cd "$1"
}
Should've made this a long time ago:
function ciglob {
#case-insensitive glob generator
echo "$*" |while read -N1 c; do
case "$c" in
[a-zA-Z]) echo -n "[${c^^}${c,,}]";;
*) echo -n "$c"
esac
done
}
~ $ ciglob "Hello, world!"
[Hh][Ee][Ll][Ll][Oo], [Ww][Oo][Rr][Ll][Dd]!
~ $ ls -ld $(ciglob documents)
drwxr-xr-x 52 ~~~ ~~~ 20,480 Apr 10 11:45 Documents
(Not the most useful example, but I did have a use case in mind when I wrote it ;)
P.S. (This is a valid way to close a parenthesis. Fight me ;)
#bash #ksh #sh #shell #UnixShell #POSIX #PosixShell #ShellScripting
🛠️ Curious how coding can support your research?
Join our Software Carpentry Workshop for absolute beginners – no experience needed, just curiosity and motivation!
📅 May 12–13, 2025, 09:00–16:00
📍 ZB MED, Cologne
👩💻 Hands-on sessions on:
#UnixShell
#Git for version control
#Python programming
👩🏫 With @RabeaMue, Silvia Di Giorgio & Justine Vandendorpe
🔗 Register: https://zbmed.github.io/2025-05-12-Software_Carpentry_ZB_MED/
#SoftwareCarpentry #OpenScience #ResearchTools #CodingForResearchers
@jeeynet Salut, merci pour l'idée, je ne savais pas que c'était possible ! Concernant le script proposé, ce test est bizarre :
if [ "${1}" ]
Si "${1}" venait à coïncider avec un opérateur de test(1) , vous auriez des surprises. Je suggère ceci à la place :
if [[ $# -gt 0 ]]
ou bien
if [[ -n "$1" ]]
Notes :
on peut se permettre [[ … ]] car le script utilise Bash;
vous pouvez enlever les " autour de $1 dans cet exemple mais attention, c'est un cas bien particulier dû au fait que [[ … ]] ne fait pas de “word splitting” sur l'expression fournie).
Invitation: Next Library Carpentry Workshop takes place online on January 20 to 24 together with #EMBL. Information and registration: https://zbmed.github.io/2025-01-20-LC_EMBL-online/
#SQL #UnixShell #Python #LibraryCarpentry
@thecarpentries
In a #bash alias:
do something
printf "[ctrl-v] [up-arrow] [ctrl-v] [up-arrow] [ctrl-v] [up-arrow]"
echo something
Whoa, that actually worked?!?
I just got the most retro #Commodore64 feeling from bash of all things. XD
My master's thesis "Understanding the role of Unix shell in software development and developer experience" is now available online!
Explore how developers use the shell, their emotions towards it, and its impact on developer experience.
$ cat > file <<EOF
your file
content goes
here
EOF
Más de 10 años viviendo es esto y aún se me olvida como escribir ficheros en Unix sin recurrir a editores de texto ¬¬
🚀 Neues Video ist live! 🐚 Entdecke die #UnixShell mit meinem interaktiven Screencast. Von der Installation bis zum Shell-Skript – alles dabei! 🌟 Die #LibraryCarpentry Lesson online zum Mitmachen💡💻 https://youtu.be/L3JRQC_tZ4E?si=lZlkHW9hkyUPVKzk