Isn’t the ‘date’ command much simpler? No need for awk, stat, etc.
date -r <filename>
Also, consider looking at the man page for date formatting; for example with common date and time format:
date -r <filename> "+%m-%d-%Y %H:%M:%S"
More Related Contents:
- Validate date format in a shell script
- What does 2>&1 mean here?
- In the shell, what does ” 2>&1 ” mean?
- Difference between sh and Bash
- Pass commands as input to another command (su, ssh, sh, etc)
- Why do you need ./ (dot-slash) before executable or script name to run it in bash?
- Bash command line and input limit
- How to find the difference in days between two dates?
- How do I check if a directory exists in a Bash shell script?
- Checking from shell script if a directory contains files
- How to determine the current interactive shell that I’m in (command-line)
- Convert date time string to epoch in Bash
- YYYY-MM-DD format date in shell script
- How to suppress Terminated message after killing in bash?
- How to represent multiple conditions in a shell if statement?
- Copy folder recursively, excluding some folders
- Variable interpolation in the shell
- Piping tail output though grep twice
- How do I pause my shell script for a second before continuing?
- How to go to each directory and execute a command?
- What does ” 2>&1 ” mean?
- What’s a concise way to check that environment variables are set in a Unix shell script?
- Bash regex =~ operator
- executing shell command in background from script [duplicate]
- How do I check if a directory exists or not in a Bash shell script?
- Waiting for background processes to finish before exiting script
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- How can I convert tabs to spaces in every file of a directory?
- How to properly nest Bash backticks
- How to wait on all child (and grandchild etc) process spawned by a script