Skip to content

Instantly share code, notes, and snippets.

@letam
Created February 9, 2020 08:11
Show Gist options
  • Save letam/2e5b0f2f61d46fe55711c0124e3e4394 to your computer and use it in GitHub Desktop.
Save letam/2e5b0f2f61d46fe55711c0124e3e4394 to your computer and use it in GitHub Desktop.
List file time values (created, modified, accessed) on Debian/Ubuntu Linux
#!/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