Skip to content

Instantly share code, notes, and snippets.

@hicolour
Created December 20, 2022 22:09
Show Gist options
  • Save hicolour/e198fca073811897a055ff02d7cce95e to your computer and use it in GitHub Desktop.
Save hicolour/e198fca073811897a055ff02d7cce95e to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ ! $1 ]]; then
echo -e "Usage:\n\n\t$0 'file name'"
exit 1
fi
f=$(file 2>/dev/null /proc/*/fd/* | awk '$NF == "(deleted)"{print $(NF-1)}')
if [[ $f ]]; then
echo "fd $f found..."
cp -v "$f" "$1"
else
echo >&2 "No fd found..."
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment