Shell Script That Display The Last Modification Time Of Any File

in Categories File-management last updated September 13, 2008
# Write a shell script that displays the last modification time of any file.
# -------------------------------------------------------------------------
# Copyright (c) 2008 nixCraft project <>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit for more information.
# -------------------------------------------------------------------------
echo -n "Enter a filename to see last modification time : "
read fileName
# make sure file exits
if [ ! -f $fileName ]
	echo "$fileName not a file"
	exit 1
# use stat command to display 
echo "$fileName was last modified on $(stat -c %x $fileName)"

Share this on:

1 comment

  1. % x will NOT give time modified it will give time of last ACCESS its %y that gives time of last modification this i think though might vary across bash versions i am just going off the Manual pge in my possession

Leave a Comment