Regarding equating file attributes in "ls" command
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Regarding equating file attributes in "ls" command
I have a folder in which there are thousands of images. Of those thousand images, I want to bring together all those images whose “Last created” and “Last modified” attributes are exactly same.
( In other words, I want to separate all the images I didn’t ever rename for example )
Is there a way to do this from terminal ?
these are the two commands that I want to concatenate ls -tU lists file by creation date. (I'm on a mac) ls -lt lists file by modified date
such that I want to
"List files whose date created = date modified"
Last edited by t@sh; 06-18-2016 at 08:47 AM.
Reason: properties = attributes
If you are using a file system that supports "time of file birth" in "stat" then you can do it. But as far as I know, EXT4 and HFS+ don't. You can check with "stat" on a file:
Code:
stat -c "%Y %W" ./somefile
That will print out two numbers, if the second is zero then you cannot find the creation time of the file and you'll have to try a different approach. If the second number is not zero, then you can do it if you make "find" jump through some hoops with the option -exec and the program "test"
The usual problem is that no two files are created at "exactly the same time".
If you look at the file dates using the stat command, you will see timestamps into the nanosecond range - thus the dates are almost guaranteed to be unique.
Depending on how the files are modified/backed up/restored the modified timestamp MAY be recorded to the second.
But the access/creation/birth (if recorded) will be to the nanosecond.
cd directory
stat -f "%c:%a:%N" * | awk -F: '$1 != $2 {print $3}'
%c: time when the inode was last changed
%a: time when file was last accessed
%N: file name
I don't know what you are looking for, but if you CHANGE a file, you are also ACCESSING the file...
Also note that some backup/restore facilities can set the changed and modification dates to whatever is desired...(see "touch" command), and neither has anything to do with created date (which is more properly called "inode modification date").
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.