Skip to content

Instantly share code, notes, and snippets.

@joaociocca
Created January 27, 2024 22:00
Show Gist options
  • Save joaociocca/b5e0bda324da1ed2c816d64325aebe37 to your computer and use it in GitHub Desktop.
Save joaociocca/b5e0bda324da1ed2c816d64325aebe37 to your computer and use it in GitHub Desktop.
process print-pit file from Heimdall to flash Samsung Galaxy devices
#!/usr/bin/env bash
heimdall print-pit > print-pit.txt
grep -Poz "(?<=Partition Name: ).*\nFlash Filename:.*" print-pit.txt | sed ':a;N;$!ba;s#\n##g;s#Flash Filename:##g;s#\x00#\n#g' > prep-pit.1
while read line; do file=$(echo "$line" | cut -d' ' -f2); if [[ -f $file ]]; then echo "$line" >> prep-pit.2; fi; done < prep-pit.1
sudo heimdall flash "$(cat -p prep-pit.2 | sort -u | tr '\n' ' ')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment