2022-10-05 15:36:12 +02:00
|
|
|
#+TITLE: Erwin's NixOS config
|
|
|
|
|
|
|
|
This configures my machines.
|
|
|
|
|
|
|
|
* Useful oneliners
|
|
|
|
** Remove all files except the smallest
|
|
|
|
|
|
|
|
#+begin_example
|
|
|
|
$ ls -s size | head -n 1 | xargs stat -c %s | awk '{print $1 + 1}' | xargs -I '%S' fd -S +%Sb -X rm {} \;
|
|
|
|
#+end_example
|
|
|
|
|
|
|
|
| cmd | Explanation |
|
|
|
|
|--------------------------------------+-----------------------------------------------------------------|
|
2023-09-11 20:11:08 +02:00
|
|
|
| =ls -s size= | List all files, sort by size (=ls= is aliased to =eza= in my setup) |
|
2022-10-05 15:36:12 +02:00
|
|
|
| =head -n 1= | Take the first line |
|
|
|
|
| =xargs stat -c %s= | Print the size in bytes |
|
|
|
|
| =awk '{print $1 + 1}= | Add one to it |
|
|
|
|
| =xargs -I '%S' fd -S +%Sb -X rm {} \;= | Find all files larger than the smallest and delete them |
|