Monday, February 07, 2022

How to find total filesize grouped by extension

find . -name '*' -type f -printf '%b.%f\0' | awk -F . -v RS='\0' '{if (NF==2) $(NF+1)=" "; s[$NF] += $1; n[$NF]++} END {for (e in s) printf "%15d %6d  %s\n", s[e]*512, n[e], e}' | sort -rn | numfmt --to=iec-i --suffix=B

How can I recursively delete all files of a specific extension in the current directory?

You don't even need to use rm in this case if you are afraid. Use find:

find . -name "*.bak" -type f -delete
But use it with precaution. Run first:

find . -name "*.bak" -type f
to see exactly which files you will remove.

Sunday, February 06, 2022

Unzip All Files In A Directory

This works in bash, according to this link:

unzip \*.zip


or 


Just put in some quotes to escape the wildcard:

unzip "*.zip"

Saturday, January 22, 2022

Ubuntu – Increase number of old kernels to keep on autoremove

So I looked into the script a little bit and some minor changes was enough to get what you want.

First create a backup of: /etc/kernel/postinst.d/apt-auto-removal:

sudo cp /etc/kernel/postinst.d/apt-auto-removal{,.bk}

Then find this line:

previous_version="$(echo "$debverlist" | sed -n 2p)"

and change it to:

previous_version="$(echo "$debverlist" | sed -n 2,4p)"
  • Now it should keep 3 old kernel + Running + Newly installed one
  • Of course you have to run it once manually or install a new kernel to make it take effect.

Thursday, December 16, 2021

Max disk cache size in google chrome

 Google chrome stores cache size as a signed integer, so the maximum size is 2147483647 bytes or just under 2gb.


reset;

/usr/bin/google-chrome %U --disk-cache-dir='/tmp/google-chrome/' --disk-cache-size=2147483647

systemd-timesyncd

sudo apt update && sudo apt install systemd-timesyncd && sudo systemctl enable --now systemd-timesyncd