Skip to content

@ashayh /crtime.sh
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Extract ext4 creation (crtime) of file
#!/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
Something went wrong with that request. Please try again.