Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Privacy & data protectionMixed 24 series

Data discovery and deletion commands

Discovery and deletion are the same skill pointed in two directions. You cannot delete what you cannot find, and a discovery tool that never deletes is just an inventory.

Quick reference

Four blocks, twenty commands, one receipt.

Discover

rg -n 'email|phone' --glob '*.json'
psql -c '\d+ customers'
find . -name '*.csv' -size +1M
aws s3 ls s3://exports --recursive
sqlite3 app.db '.schema users'

Scan

rg -c '@[a-z0-9.-]+' exports/
csvcut -n exports/customers.csv
head -1 exports/*.csv | sort -u
jq -r '.. | .email? // empty' dump.json
rg -l 'passport|iban|ssn' --type json

Delete

shred -u -z exports/customers.csv
find /exports -mtime +90 -delete
drop table events_2023_01;
aws s3 rm s3://exports/2023/ --recursive
redis-cli del session:alice

Verify

psql -c 'select count(*) from customers'
aws s3 ls s3://exports/2023/
rg -c 'email' /var/log/app/*.log
sha256sum exports/customers.csv
aws cloudtrail lookup-events --max-items 5

In one line: Discovery without deletion is just inventory. A deletion you cannot prove is a promise.

Prove it is gone:

aws s3 ls s3://exports/2023/

Explained

Start with discovery. Search the repository for field names and patterns, list the columns in the busiest tables, find the large CSV files nobody remembers exporting, list the object store prefixes, and read the schema of the local database. Each command answers a small question; together they sketch the map.

Then scan the exports. Count matches for an email pattern, list the columns in a CSV, compare headers across files, pull nested values out of JSON, and search for identifiers such as passport or IBAN. This is where pattern matching earns its keep, and where it stops: a name in a support note is invisible to a regex.

Then delete and verify. Shred a file, drop a partition, remove an object prefix, confirm the prefix is empty, and pull the audit events that prove the job ran. Keep the receipt with the job.

The honest caveat: every delete command here is irreversible, and a wildcard in the wrong directory removes the wrong data. Run it against a copy first, with a name that cannot match production.

Your turn: Which command would prove your last deletion actually happened?

More notes: Privacy & data protection

Open in the notes app: search, filters, copy This note on GitHub