Created
November 11, 2023 15:01
-
-
Save kannangce/0a121cff1c6b40cd72dbd6ab0511e23b to your computer and use it in GitHub Desktop.
Bash script to get the created time of a 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
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