0
score
|
Report disk usage by file type$ find . -type f -empty -prune -o -type f -printf "%s\t" -exec file --brief --mime-type '{}' \; | awk 'BEGIN {printf("%12s\t%12s\n","bytes","type")} {type=$2; a[type]+=$1} END {for (i in a) printf("%12u\t%12s\n", a[i], i)|"sort -nr"}' |
0
score
|
Find with invert match - e.g. find every file that is not mp3$ find . -name '*' -type f -not -path '*.mp3' |
0
score
|
Convert pip list --outdated for reuse in pip install -U$ python3 -m pip install -U $(python3 -m pip list outdated 2> /dev/null | grep -v 'Version' | grep -v '\-\-\-\-\-\-' | awk '{printf $1 " " }' && echo) |
0
score
|
Recursively remove all "node_modules" folders$ find . -name "node_modules" -exec rm -rf '{}' + |
0
score
|
Read other user's shell history, and convert epoch to human-readable date$ cat /home/john/.bash_history | awk '/#[0-9]*$/ {split($0, arr, "#"); print "#", strftime("%c",arr[2]);getline; print; }' |
0
score
|
Prints "Good" in green if the sha256 sum of a file matches the sum listed in a dist/checksum file and "Bad" in red if it does not match$ [[ $(sha256sum _downloaded_file_ | cut -d' ' -f 1) == $(grep -Po '\b[a-zA-Z0-9]{64}\b' _checksum_fle_) ]] && printf "\033[0;32mGood" || printf "\033[0;31mBad" |
0
score
|
(Pseudo)random 6-digit number$ let N=0 N=N+10**{0..5}*${RANDOM:0:1} |
0
score
|
Compute factorial of positive integer using only built-ins$ bang() ( eval let N=1 N*={1..$1} ; echo $N; ) |
0
score
|
Recursively compute factorial of positive integer using only built-ins$ bang() ( IFS=\*; let N=$1-1 k="$*" && bang $N $k || echo ${2-1} ) |
0
score
|
List docker log sizes and remind how to empty them$ docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs sudo du -hl; sleep 1; printf "\r\n echo '' > \$(docker inspect --format={{.LogPath}} container_name_or_id) \r\n*****COPY****ABOVE****TO******CLEAR*****LOG*****CHANGE***CONTAINER_ID******* \r\n \n" |
0
score
|
Extract audio only from video files using ffmpeg$ ffmpeg -i video.any -vn -acodec libvorbis audio.ogg |
0
score
|
Print the list of your Git commits this month$ git log --since='last month' --author="$(git config user.name)" --oneline |
0
score
|
Store the output of find in an array$ mapfile -d $'\0' arr < <(find /path/to -print0) |
0
score
|
While loop to pretty print system load (1, 5 & 15 minutes)$ while :; do date; awk '{printf "1 minute load: %.2f\n", $1; printf "5 minute load: %.2f\n", $2; printf "15 minute load: %.2f\n", $3}' /proc/loadavg; sleep 3; done |
0
score
|
Scan entire Git repos for dangerous Amazon Web Service IDs$ git ls-tree --full-tree -r --name-only HEAD | xargs egrep -w '[A-Z0-9]{20}' |
0
score
|
While loop to pretty print system load (1, 5 & 15 minutes)$ while [ 1 == 1 ]; do cat /proc/loadavg | awk '{printf "1 minute load: %.2f\n", $(NF-5)}' && cat /proc/loadavg |awk '{printf "5 minute load: %.2f\n", $(NF-3)}' && cat /proc/loadavg |awk '{printf "15 minute load: %.2f\n", $(NF-2)}'; sleep 3; date; done |
0
score
|
Organise image by portrait and landscape$ mkdir "portraits"; mkdir "landscapes"; for f in ./*.jpg; do WIDTH=$(identify -format "%w" "$f")> /dev/null; HEIGHT=$(identify -format "%h" "$f")> /dev/null; if [[ "$HEIGHT" > "$WIDTH" ]]; then mv "$f" portraits/ ; else mv "$f" landscapes/ ; fi; done |
0
score
|
Create a txt files with 10000 rows$ for FILE in *.full ; do split -l 100000 $FILE; mv -f xaa `echo "$FILE" | cut -d'.' -f1`.txt; rm -f x*; done |
0
score
|
Remove all container from an specific network (docker)$ docker ps -a -f network=$NETWORK --format='{{.ID}}' | xargs docker rm -f |
0
score
|
Up all docker services as detached mode over all immediate subdirectories$ for dir in $(ls -d */); do eval $(cd $PWD/$dir && docker-compose up -d && cd ..); done; |
0
score
|
Find and replace string inside specific files$ grep -ril '$SEARCH_PATTERN' src | sed -i 's/$FIND_PATTERN/$REPLACE_PATTERN/g' |
0
score
|
Puppet/Bash: test compare json objects.$ unless => "client_remote=\"$(curl localhost:9200/_cluster/settings | python -c \"import json,sys;obj=json.load(sys.stdin);print(obj['persistent']['search']['remote'])\")\"; new_remote=\"$( echo $persistent_json | python -c \"import json,sys;obj=json.load(sys.stdin);print(obj['persistent']['search']['remote'])\")\"; [ \"$client_remote\" = \"$new_remote\" ]", |
0
score
|
Print wifi access points sorted by signal$ iw dev IFACE scan | egrep "SSID|signal" | awk -F ":" '{print $2}' | sed 'N;s/\n/:/' | sort |
0
score
|
Delete all untagged Docker images$ docker images -q -f dangling=true | xargs --no-run-if-empty --delim='\n' docker rmi |
0
score
|
Source without circular reference$ [ ! "${LIB}" ] && ( readonly LIB; . "${ $( cd $( dirname $0 ) && pwd ) }/<path_to>/LIB.sh" ) |