Skip to content

Instantly share code, notes, and snippets.

@alghanmi
Created May 13, 2012 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alghanmi/2684803 to your computer and use it in GitHub Desktop.
Save alghanmi/2684803 to your computer and use it in GitHub Desktop.
Recover an Accidentally Deleted Text File
#!/bin/bash
# Some text available in the file
SAMPLE_TEXT=$1
# The dev path for the media with the deleted file, e.g. /dev/sda2
HDD=$2
# The file used to store the output
RECOVERY_FILE=$3
sudo grep -a -B 25 -A 100 "$SAMPLE_TEXT" $HDD > $RECOVERY_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment