grex is a command-line tool and library for generating regular expressions from user-provided test cases: https://github.com/pemistahl/grex

grex is a command-line tool and library for generating regular expressions from user-provided test cases: https://github.com/pemistahl/grex
Variables · Functions · Interpolation · Brace expansions · Loops · Conditional execution · Command substitution · One-page guide to Bash scripting
Source: Bash scripting cheatsheet
On human feedback loops: https://t.co/KBNRCQeoGU
— Daniel Gross 💡 (@danielgross) March 9, 2018
Want to Teach Kids to Code? Send ‘Em to a ‘Hack Jam’
100 Kids and their adults gathered last weekend in Los Angeles to learn how to program, how to think, and how to start making things. This is what happened and why.
The other day I had enough calculating the time so I just wrote this script:
cat > ~/bin/timediff
#!/bin/sh
if [ -z $2 ]; then
echo "usage: $0
echo
echo "ex. $0 11:49 12:51"
exit 1
fi
end=`date +%s -d"$2"`
start=`date +%s -d"$1"`
diff=$(($end-$start))
diff=$(($diff/60))
hours=$(($diff/60))
min=$(($diff%60))
# Prepend a 0 if minute <10
if [ ${#min} -eq 1 ]; then
min=0$min
fi
echo "$hours:$min"
Of course, it works in some cases only. This one is fine:
$ sh ~/bin/timediff 11:49 12:51
1:02
Whereas this one will not work:
$ sh ~/bin/timediff 11:49 1:51
-9:-58
But the output is quite obvious.
I hear it all the time, I have issue with it, so this time i know how it does work a bit more.
thanks to the following : ACPI explained