I have edited above to include the source. This is very well addressed in another question. If you used this question, you should cite it in your question.
In Linux, date -r
file prints the date when the file was last modified:
date +%s -r file.txt
To print the seconds elapsed since the last modification, you can use expr with the current date in seconds minus the date of the last modification:
expr $(date +%s) - $(date +%s -r file.txt)
In Mac OS X (BSD flavor of date) this won't work, you'd need to use stat as other answers pointed out.
echo $(( $(date +%s) - $(stat -f%c myfile.txt) ))
And as a function to be called with the file name:
lastmod(){
echo "Last modified" $(( $(date +%s) - $(stat -f%c "$1") )) "seconds ago"
}
The only thing that could be messed up is either your variable $videoName or how to save it as a variable. This is how I did it on a mac with no problem (01_movie.flv is a random video file of mine):
#!/usr/bin/env bash
videoName=01_movie.flv
time=`echo $(( $(date +%s) - $(stat -f%c $videoName) ))`
echo $time
Printed to the terminal:
956680