Skip to main content

Linux shell script get file timestamp as seconds

This is accomplished using stat command.
-c parameter is for the specified FORMAT instead of the default
%Y is for the Time of last modification as seconds since Epoch

file_time_stamp=$(stat -c %Y $file)
echo $file_time_stamp


Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.