Skip to content

Instantly share code, notes, and snippets.

@isaaclw
isaaclw / rebootgrub2os.sh
Created November 22, 2019 16:37
Reboot Grup to the specific OS you specify #grub #bash
#!/bin/bash
if ! grep "GRUB_DEFAULT=saved" /etc/default/grub > /dev/null; then
sudo sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/' /etc/default/grub
fi
echo
echo "== SELECT WHICH OS TO BOOT =="
echo
sudo cat /boot/grub/grub.cfg | grep -oE "^menuentry '[^']+'" | awk -F\" '{print N++,$(NF-1)}'
@isaaclw
isaaclw / random_words
Created November 25, 2019 15:02
List 10 random words #bash
#!/bin/bash
WORDFILE="/usr/share/dict/words"
NUMWORDS=10
#Number of lines in $WORDFILE
tL=`awk 'NF!=0 {++c} END {print c}' $WORDFILE`
for i in `seq $NUMWORDS`; do
rnum=$((RANDOM%$tL+1));
sed -n "$rnum p" $WORDFILE;
@isaaclw
isaaclw / wordle.sh
Last active November 27, 2022 15:11
wordle
#!/bin/bash
INCLUDE=
EXCLUDE=
COUNT=
while getopts ":i:e:m:ch" flag; do
case $flag in
i|include) INCLUDE="$OPTARG";;
e|exclude) EXCLUDE="$OPTARG";;
c|count) COUNT=1;;