this post was submitted on 12 Jul 2023
14 points (85.0% liked)
Linux
59158 readers
390 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Sure, here is a simple Bash script which uses the
statcommand to get the modification time of files. It looks specifically for.jpgand.mp4files in the current directory and prints out the modification date and time, including seconds:This script will print out the filename along with its modification date for each .jpg and .mp4 file.
You can use this script by saving it in a file (for example,
filedate.sh), making it executable withchmod +x filedate.sh, and running it with./filedate.sh.Please note that the date format of the
statcommand can vary based on your system. The%yformat outputs the last modification time in human readable format (yyyy-mm-dd hh:mm:ss.sssssssss +zone). You might need to adjust this if you are using a system wherestatbehaves differently.Also keep in mind that this script does not traverse directories recursively. It only looks for the specified files in the directory where it is executed. If you need to perform this operation on files in subdirectories, you will need to modify the script slightly or use a different approach.
@Pyrozo007@lemmy.dbzer0.com does it look like something you are looking for? The check for file existence is unneeded IMO and using the
filevariable name occludes another binary but in this case it shouldn't hurt the execution