Skip to content

Instantly share code, notes, and snippets.

@kannangce
Created November 11, 2023 15:01
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 kannangce/0a121cff1c6b40cd72dbd6ab0511e23b to your computer and use it in GitHub Desktop.
Save kannangce/0a121cff1c6b40cd72dbd6ab0511e23b to your computer and use it in GitHub Desktop.
Bash script to get the created time of a file.
get_crtime() {
for target in "${@}"; do
inode=$(stat -c '%i' "${target}")
fs=$(df --output=source "${target}" | tail -1)
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null |
grep -oP 'crtime.*--\s*\K.*')
printf "%s\t%s\n" "${target}" "${crtime}"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment