Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Last active September 21, 2025 06:31
Show Gist options
  • Select an option

  • Save xbalaji/5a36a9c2acc99d2388479448d6f5229b to your computer and use it in GitHub Desktop.

Select an option

Save xbalaji/5a36a9c2acc99d2388479448d6f5229b to your computer and use it in GitHub Desktop.
firefox-delete-temporary-containers.sh
#!/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
@xbalaji

xbalaji commented Jul 31, 2020

Copy link
Copy Markdown
Author

make it public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment