Skip to content

Instantly share code, notes, and snippets.

@ivoarch
Forked from moiseevigor/xstat
Created November 24, 2015 23:32
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 ivoarch/19a399be4e6f6c47c086 to your computer and use it in GitHub Desktop.
Save ivoarch/19a399be4e6f6c47c086 to your computer and use it in GitHub Desktop.
xstat bash function to get file creation time on Linux with EXT4
xstat() {
for target in "${@}"; do
inode=$(ls -di "${target}" | cut -d ' ' -f 1)
fs=$(df "${target}" | tail -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