Last active
August 1, 2020 19:41
-
-
Save xbalaji/5a36a9c2acc99d2388479448d6f5229b to your computer and use it in GitHub Desktop.
firefox-delete-temporary-containers.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# cleanup containers.json (remove tmp containers, sort them by name) | |
# open command prompt in profiles directory and execute | |
cp containers.json c01.json | |
jq -r '.' c01.json | tr -d '\r' | tac | sed '/name.*tmp/{n;N;N;N;N;d}' | tac | sed '/name.*tmp/,+1d' | yq '.' | jq '.identities|=sort_by(.name)' > containers.json | |
preserve="" | |
for id in $(jq -r '.identities[] | .userContextId' containers.json | tr -d '\r' | sort -rn); do | |
preserve="$id\|$preserve" | |
done; | |
# delete the unused containers from storage | |
find storage/default -mindepth 1 -maxdepth 1 -type d -name "about*" -regex ".*\^userContextId=[0-9]+\$" -not -regex ".*\^userContextId=\($preserve\)\$" -exec rm -rf {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make it public