Sponsored Content
Top Forums Shell Programming and Scripting Bash directory loop and order by creation date? Post 302986778 by drl on Wednesday 30th of November 2016 06:39:26 AM
Old 11-30-2016
Hi.
Quote:
Originally Posted by apmcd47
...so, --time=ctime to sort by creation time ...
Quote:
ctime

ctime originally meant creation time,[12] however it has since been used almost always to refer to inode change time. It is updated any time file metadata stored in the inode changes, such as file permissions, file ownership, and creation and deletion of hard links. In some implementations, ctime is affected by renaming a file (both original Unix and modern Linux tend to do this).

Unlike atime and mtime, ctime cannot be set to an arbitrary value with utime(), as used by the touch utility, for example. Instead, when utime() is used, the ctime value is set to the current time.
Excerpt from stat (system call) - Wikipedia
Quote:
Change time and creation time (ctime)

Unix and Windows file systems interpret 'ctime' differently:

Unix systems maintain the historical interpretation of ctime as being the time when certain file metadata, not its contents, were last changed, such as the file's permissions or owner (e.g. 'This file's metadata was changed on 05/05/02 12:15pm').
Windows systems use ctime to mean 'creation time'[citation needed] (also called 'birth time') (e.g. 'This file was created on 05/05/02 12:15pm').

This difference in usage can lead to incorrect presentation of time metadata when a file created on a Windows system is accessed on a Unix system and vice versa.[citation needed] Most Unix file systems don't store the creation time, although some, such as HFS+, ZFS, and UFS2 do. NTFS stores both the creation time and the change time.

The semantics of creation times is the source of some controversy. One view is that creation times should refer to the actual content of a file: e.g. for a digital photo the creation time would note when the photo was taken or first stored on a computer. A different approach is for creation times to stand for when the file system object itself was created, e.g. when the photo file was last restored from a backup or moved from one disk to another.
Excerpt from: MAC times - Wikipedia

Best wishes ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. AIX

loop through the directory for files and sort by date and process the first file

hello i have a requirement where i have a direcotry in which i get files in the format STOCKS.20080114.dat STOCKS.20080115.dat STOCKS.20080117.dat STOCKS.20080118.dat i need to loop through the directory and sort by create date descending order and i need to process the first file. ... (1 Reply)
Discussion started by: dsdev_123
1 Replies

2. Shell Programming and Scripting

Grep by range of date from file creation in directory

Hi Expert, Need your scripting and finding data so that it help me to find the culprit of this memory usage error. Data provided here is a sample. Process Snapshot directory: /var/spool/processes-snapshot webdev9o9% pwd /var/spool/processes-snapshot webdev9o9% ls -lrct -rw-r--r-- ... (3 Replies)
Discussion started by: regmaster
3 Replies

3. Shell Programming and Scripting

Creation date of a directory

what's the command to find the creation date of a certain dirctory? (1 Reply)
Discussion started by: miss_dodi
1 Replies

4. Shell Programming and Scripting

Move files from one directory to another based on creation/modification date

Hi All, Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates. While visiting couple of posts, i could see we can... (3 Replies)
Discussion started by: dsfreddie
3 Replies

5. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

6. Shell Programming and Scripting

Bash to create new directory by date followed by identifier and additional subdirectories

I have a bash that downloads a list and if that list has data in it then a new main directory is created (with the date) with several subdirectories (example1, example2, example3). My question is in that list there are portion of specific file types (.vcf.gz) - identifier towards the end that have... (0 Replies)
Discussion started by: cmccabe
0 Replies

7. Shell Programming and Scripting

Bash directory loop, but only choose those folders with specific word in it

Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word #!/bin/bash for filename in /home/test/* do if ; then echo $filename; fithx! (4 Replies)
Discussion started by: ZerO13
4 Replies

8. UNIX for Beginners Questions & Answers

Copy files in order of creation date

Hi everyone :-) I ran into a small issue. I would like to copy some files in the precise order they were created. So the oldest files should be copied first and the newest ones last. I tried cp -r $(ls -1t) ./destination but the files are still not sorted properly. I was thinking, that... (11 Replies)
Discussion started by: officiallyme
11 Replies

9. Shell Programming and Scripting

Reason for no directory creation date

i read here that linux provides no way to determine when a directory was created. https://www.unix.com/shell-programming-and-scripting/157874-creation-date-directory.htmlI have a directory /home/andy/scripts that had a README file in it. That file says I put the script in that directory and... (3 Replies)
Discussion started by: drew77
3 Replies

10. UNIX for Beginners Questions & Answers

Help with date in bash script for loop from YYYYMMDDHHMM

Hi everyone I need some help I want to create an script which does some processing it takes the two arguments 201901010000 and 201901020200 - so YYYMMDDHHMM I want to split processing into hours from start until end, I dont get why this works but when I add to a future variable... (1 Reply)
Discussion started by: kl1ngac1k
1 Replies
CTIME(P)						     POSIX Programmer's Manual							  CTIME(P)

NAME
ctime, ctime_r - convert a time value to a date and time string SYNOPSIS
#include <time.h> char *ctime(const time_t *clock); char *ctime_r(const time_t *clock, char *buf); DESCRIPTION
For ctime(): The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to the ISO C standard. The ctime() function shall convert the time pointed to by clock, representing time in seconds since the Epoch, to local time in the form of a string. It shall be equivalent to: asctime(localtime(clock)) The asctime(), ctime(), gmtime(), and localtime() functions shall return values in one of two static objects: a broken-down time structure and an array of char. Execution of any of the functions may overwrite the information returned in either of these objects by any of the other functions. The ctime() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe. The ctime_r() function shall convert the calendar time pointed to by clock to local time in exactly the same form as ctime() and put the string into the array pointed to by buf (which shall be at least 26 bytes in size) and return buf. Unlike ctime(), the thread-safe version ctime_r() is not required to set tzname. RETURN VALUE
The ctime() function shall return the pointer returned by asctime() with that broken-down time as an argument. Upon successful completion, ctime_r() shall return a pointer to the string pointed to by buf. When an error is encountered, a null pointer shall be returned. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
Values for the broken-down time structure can be obtained by calling gmtime() or localtime(). The ctime() function is included for compati- bility with older implementations, and does not support localized date and time formats. Applications should use the strftime() function to achieve maximum portability. The ctime_r() function is thread-safe and shall return values in a user-supplied buffer instead of possibly using a static data area that may be overwritten by each call. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
asctime() , clock() , difftime() , gmtime() , localtime() , mktime() , strftime() , strptime() , time() , utime() , the Base Definitions volume of IEEE Std 1003.1-2001, <time.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 CTIME(P)
All times are GMT -4. The time now is 05:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy