ITT: post useful bash one-liners
Here's what I use to remove duplicate astolfo pics from my computer!while true; do rm -v "$(find astolfo* | xargs -d '\n' md5sum | sort | uniq -D -w 32 | cut -c 34- | tail -1)"; done
>>62277584
SHE MUH TRAP QUEEN
i don't do one liners cuz they suck# faster urandom source using openssl
urandom() {
head --bytes=128 /dev/urandom 2>/dev/null \
| base64 \
| openssl enc -aes-256-ctr \
-in /dev/zero \
-nosalt \
-pass stdin \
2>/dev/null
}
mostly irrelevant since the kernel cucks made urandom some salsa20 bullshit stream cipher but it's still faster.
this is one i use for colorizing PS1's to differentiate different hosts.# $1 - get hash of string
# common colored name algo
color_hash() {
declare -i chr hash_val i len
chr=0
hash_val=0
len=${#1}
# i=1 because zsh indexing
for (( i=1; i<len+1; ++i )); do
chr=$(printf '%d' \'"${1[$i]}")
hash_val=$(( hash_val * 32 - hash_val + chr ))
done
echo "$hash_val"
}
this might be zsh specific given the whole string char access.
for bash cucks, just change ${1[$i]} to ${1:$i:1}