Skip to content

Instantly share code, notes, and snippets.

@gnought
Forked from moiseevigor/xstat
Last active August 29, 2015 14:28
Show Gist options
  • Save gnought/1dee2fa4422f37e4d875 to your computer and use it in GitHub Desktop.
Save gnought/1dee2fa4422f37e4d875 to your computer and use it in GitHub Desktop.
xstat bash function to get file creation time on Linux with EXT4
# For working in Centos 7
xstat() {
for target in "${@}"; do
inode=$(ls -di "${target}" | cut -d ' ' -f 1)
fs=$(df "${target}" | tail -2 | head -n 1 | awk '{print $1}')
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null |
grep -oP 'crtime.*--\s*\K.*')
printf "%s\t%s\n" "${crtime}" "${target}"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment