2
score
|
Rename all files in the current directory by capitalizing the first letter of every word in the filenames$ ls | perl -ne 'chomp; $f=$_; tr/A-Z/a-z/; s/(?<![.'"'"'])\b\w/\u$&/g; print qq{mv "$f" "$_"\n}' |
2
score
|
Remove spaces recursively from all subdirectories of a directory$ find /path/to/dir -type d | tac | while read LINE; do target=$(dirname "$LINE")/$(basename "$LINE" | tr -d ' '); echo mv "$LINE" "$target"; done |
2
score
|
Rename all files in a directory to lowercase names$ paste <(ls) <(ls | tr A-Z a-z) | while read OLD NEW; do echo mv -v $OLD $NEW; done |
1
score
|
Using a single sudo to run multiple && arguments$ sudo -s <<< 'apt update -y && apt upgrade -y' |
1
score
|
Generate a sequence of numbers$ for i in {1..10};do echo $i;done |
1
score
|
Scan all open ports without any required program$ for i in {1..65535}; do (echo < /dev/tcp/127.0.0.1/$i) &>/dev/null && printf "\n[+] Open Port at\n: \t%d\n" "$i" || printf "."; done |
1
score
|
Using tcpdump with port ranges and file count/size$ sudo /usr/sbin/tcpdump -i any -s 0 -n -Z <user_name> -C 500 -W 100 -w /home/<user_name>/$(hostname).pcap -f '(port (# or # or # or # or # or # or ...) or portrange <start>-<end>)' &>/dev/null |
1
score
|
Compare (diff) vim-generated backup of a file with that file's current version.$ diff~() { diff "$1"~ "$1"; } |
1
score
|
Count the total number of hours of your music collection$ find . -print0 | xargs -0 -P 40 -n 1 sh -c 'ffmpeg -i "$1" 2>&1 | grep "Duration:" | cut -d " " -f 4 | sed "s/.$//" | tr "." ":"' - | awk -F ':' '{ sum1+=$1; sum2+=$2; sum3+=$3; sum4+=$4; if (sum4 > 100) { sum3+=1; sum4=0 }; if (sum3 > 60) { sum2+=1; sum3=0 }; if (sum2 > 60) { sum1+=1; sum2=0 } if (NR % 100 == 0) { printf "%.0f:%.0f:%.0f.%.0f\n", sum1, sum2, sum3, sum4 } } END { printf "%.0f:%.0f:%.0f.%.0f\n", sum1, sum2, sum3, sum4 }' |
1
score
|
Clear the Exim Queue (remove all messages)$ exim -bp | exiqgrep -i | xargs exim -Mrm |
1
score
|
Inspect the HTTP headers of a website$ curl -I amazon.com |
1
score
|
Random 6-digit number$ python -c 'import random; print(random.randint(0,1000000-1))' |
1
score
|
Very fast history search with Ripgrep$ rh() { rg "$1" ~/.bash_history } |
1
score
|
Scan entire Git repo for dangerous Amazon Web Service IDs$ git grep -Ew '[A-Z0-9]{20}' |
1
score
|
Dump all AWS IAM users/roles to a Terraform file for editing / reusing in another environment$ echo iamg iamgm iamgp iamip iamp iampa iamr iamrp iamu iamup | AWS_PROFILE=myprofile xargs -n1 terraforming |
1
score
|
List open processes ordered by it's number of open files$ ps -ef |awk '{ print $2 }' \ |tail -n +2 \ |while read pid; do echo "$pid $(lsof -p $pid |wc -l)"; done \ |sort -r -n -k 2 \ |while read pid count; do echo "$pid $count $(ps -o command= -p $pid)"; done |
1
score
|
Take values from a list (file) and search them on another file$ for ITEM in $(cat values_to_search.txt); do (egrep $ITEM full_values_list.txt && echo $ITEM found) | grep "found" >> exit_FOUND.txt; done |
1
score
|
Have script run itself in a virtual terminal$ tty >/dev/null || { urxvt -e /bin/sh -c "tty >/tmp/proc$$; while test x; do sleep 1; done" & while test ! -f /tmp/proc$$; do sleep .1; done; FN=$(cat /tmp/proc$$); rm /tmp/proc$$; exec >$FN 2>$FN <$FN; } |
1
score
|
Blackhole ru zone$ echo "address=/ru/0.0.0.0" | sudo tee /etc/NetworkManager/dnsmasq.d/dnsmasq-ru-blackhole.conf && sudo systemctl restart network-manager |
1
score
|
Kill a process running on port 8080$ lsof -i :8080 | awk 'NR > 1 {print $2}' | xargs --no-run-if-empty kill |
1
score
|
Kill a process running on port 8080$ lsof -i :8080 | awk '{print $2}' | tail -n 1 | xargs kill |
1
score
|
Get the latest Arch Linux news$ w3m https://www.archlinux.org/ | sed -n "/Latest News/,/Older News/p" | head -n -1 |
1
score
|
Listen to the radio (radio2 in example)$ mpv http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_med/llnw/bbc_radio_two.m3u8 |
1
score
|
Go up to a particular folder$ alias ph='cd ${PWD%/public_html*}/public_html' |
1
score
|
Preserve your fingers from cd ..; cd ..; cd..; cd..;$ up(){ DEEP=$1; for i in $(seq 1 ${DEEP:-"1"}); do cd ../; done; } |