Created
January 19, 2013 01:53
-
-
Save ashayh/4570187 to your computer and use it in GitHub Desktop.
Extract ext4 creation (crtime) of file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: ashay dot humane at gmail.com | |
# Given a file name, this script prints the file creation time, | |
# as ext4 records it | |
# Might error out on other filesystems | |
DEBUGFS="/sbin/debugfs" | |
[[ -f "$1" ]] || { echo "Invalid filename. Exiting" ; exit 1; } | |
[[ -f "$DEBUGFS" ]] || { echo "/sbin/debugfs absent. Exiting" ; exit 1; } | |
[[ $EUID != 0 ]] && { echo "You are not root. Exiting" ; exit 1 ; } | |
INODE=$(ls -i "$1" |cut -d' ' -f1) | |
DEV=$(df "$1" | awk 'NR == 2 {print $1}') | |
CMD="${DEBUGFS} -R \"stat <${INODE}>\" ${DEV} 2>/dev/null" | |
echo running: ${CMD} | |
echo | |
eval ${CMD} | grep "crtime" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment