Last active
September 21, 2025 06:31
-
-
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 | |
| # only have the non-tmp containers | |
| jq '.' containers.json > c01.json | |
| jq '.identities |= map(select(.name | test("^tmp") | not)) | .identities |= sort_by(.name) | .' c01.json > containers.json | |
| # Construct the grep pattern with 'userContextId=' for each userContextId from JSON for just the tmp containers | |
| grep_pattern=$(jq -r '.identities |= map(select(.name | test("^tmp"))) | .identities[].userContextId' c01.json | sed 's/^/userContextId=/' | paste -sd '|' -) | |
| # Use find and grep to match the directories | |
| find storage/default -mindepth 1 -maxdepth 1 -type d | grep -E "$grep_pattern" | xargs -n 1 echo | |
| find storage/default -mindepth 1 -maxdepth 1 -type d | grep -E "$grep_pattern" | xargs -t -n 1 rm -rf |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make it public