Created
February 9, 2020 08:11
-
-
Save letam/2e5b0f2f61d46fe55711c0124e3e4394 to your computer and use it in GitHub Desktop.
List file time values (created, modified, accessed) on Debian/Ubuntu Linux
This file contains hidden or 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
#!/usr/bin/env bash | |
# List file time values (created, modified, accessed) on Debian/Ubuntu Linux | |
## Reference: https://askubuntu.com/questions/470134/how-do-i-find-the-creation-time-of-a-file/470135#470135 | |
file="$1" | |
if test "" = "$file"; then echo "Error: Argument for filepath required." ; exit ; fi | |
filename="`echo "$file" | sed -E 's|.*/([^/]+)|\1|'`" | |
parent="`echo $file | sed -E "s|(.*)/$filename|\1|"`" | |
inode=`ls -xi $parent | grep -E " $filename\$" | cut -d ' ' -f1` | |
partition="`df -T $file | tail -n1 | cut -d ' ' -f1`" | |
sudo debugfs -R "stat <$inode>" $partition |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment