A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Delete all files except one on linux

Glob

  • shopt -s extglob
  • rm -v !("filename")
  • rm -v !("filename1"|"filename2")
  • rm -v !(*.zip|*.odt)
  • shopt -u extglob
Find
  • find /directory/ -type f -not -name 'PATTERN' -delete
  • find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm {}
  • find /directory/ -type f -not -name 'PATTERN' -print0 | xargs -0 -I {} rm [options] {}
  • find . -type f -not \(-name '*gz' -or -name '*odt' -or -name '*.jpg' \) -delete
Glob ignore
  • cd test
  • GLOBIGNORE=*.odt:*.iso:*.txt
  • rm -v *
  • unset GLOBIGNORE

All the homebrew packages I've installed on Mac OSX

I've used `brew install ....` many times, but now I'm regretting it because:

  • `brew update` takes so incredibly long to run, and downloads lots of unnecessary git history
  • `/usr/local/Cellar` is 3.8Gb big and I'm short on disk space
List of brew installed apps, in date order:
  • redis@4.0
  • watch
  • tree
  • dnsmasq
  • libunistring
  • libxmlsec1
  • xmlsec1
  • ack
  • putty
  • cmatrix
  • the_silver_searcher
  • ag
  • youtube-dl
  • elasticsearch@6.7
  • vbindiff
  • libpng
  • ilmbase
  • oniguruma
  • jq
  • telnet
  • gifsicle
  • fontconfig
  • tidy-html5
  • minio
  • gcc@4.9
  • autoenv # bugged: breaks "cd -"
  • direnv
  • maven@3.6
  • htop-osx
  • htop
  • xvid
  • npm
  • node@14
  • lsd
  • id3v2
  • nghttp2
  • gnutls
  • sphinx-doc
  • protobuf@3.17
  • markdown
  • postgres@13
  • ruby
  • httrack
  • chafa
  • wget
  • python@3.7
  • python2
  • coreutils
  • ctags-exuberant
  • ctags