#] #] ********************* #] "$d_SysMaint"'Linux/timestamps notes.txt' #] see functions in "$d_bin""standard header.sh" # 11Sep2017 initial 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 08********08 #] ??Sep2023 #08********08 #] 20Sep2023 pinn_timeModTo_yymmddhms() 'standard header.sh' " # pinn_timeModTo_yymmddhms() - for some-dir backups # from "$d_web"'CompLangs/PineScript/PuetzUWS IntlStkIdxs multi-fractals.txt' # 02Sep2023 initial, ignore UTC cirrection for now (not used for my p_log fNames) pinn_timeModTo_yymmddhms() { pinn="$1" timeStat=$( stat "$d_SysMaint""Linux/files - get attributes.txt" | grep 'Modify' | cut --bytes=11,12,14,15,17,18,19,20,21,22,23,24,25,26,27,28 | sed 's|:|h|g;s|\.|s|;s|h\([0-9]*\)h|h\1m|' ) date -d "$timeStat" +%s } 08********08 #] 02Sep2023 timeStat_To_timeUnix(), pinn_timeModTo_timeUnix(), timeUnix_tests() see "$d_bin""standard header.sh" 08********08 #] 02Sep2023 search "Linux stat and how do I convert stat time to Unix time?" https://unix.stackexchange.com/questions/724250/how-to-convert-a-timestamp-to-unix-epoch-time-using-bash How to convert a Timestamp to Unix Epoch time using Bash Asked 9 months ago Modified 9 months ago Viewed 2k times Like this (assuming the GNU or ast-open implementation of date): $ date -d '2022-11-09T14:41:15.555641007Z' +%s 1668004875 edited Nov 9, 2022 at 15:22 Stéphane Chazelas answered Nov 9, 2022 at 14:48 Gilles Quénot 08********08 #] 02Sep2023 search "Linux and how do I get the timestamp of a file?" I need mtime - modify time when file was last modified NOY ctime - change time, may be chmod etc changes, not the body of the file eg $ stat "$d_web"'home.html' File: /home/bill/web/home.html Size: 8990 Blocks: 24 IO Block: 4096 regular file Device: 812h/2066d Inode: 70061447 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-09-02 06:53:12.104413795 -0600 Modify: 2023-09-01 13:45:15.388594407 -0600 Change: 2023-09-02 09:42:54.615231666 -0600 Birth: 2023-08-10 09:07:42.597040623 -0600 mtime=$( stat "$d_web"'home.html' | grep 'Modify' | sed 's|Modify: ||' ) +-----+ https://superuser.com/questions/387042/how-to-check-all-timestamps-of-a-file How to check all timestamps of a file? Asked 11 years, 7 months ago Modified 7 years, 8 months ago Viewed 294k times +--+ The command is called stat. $ stat test 234881026 41570368 -rw-r--r-- 1 werner staff 0 0 "Feb 7 16:03:06 2012" "Feb 7 16:03:06 2012" "Feb 7 16:03:06 2012" "Feb 7 16:03:06 2012" 4096 0 0 test If you want to adjust the format, refer to the man pages, since the output is OS-specific and varies under Linux/Unix. Generally, you can get the times through a normal directory listing as well: ls -l outputs last time the file content was modified, the mtime ls -lc outputs last time of file status modification, the ctime (What's the difference?) ls -lu outputs last access time, the atime (although the usefulness of this concept is subject to discussion) And of course, ctime does not record when a file was "created". The POSIX specification defines only three timestamps, but some Linux filesystems store Birth Time/Creation Time. How to find creation date of file? On such a supported configuration, one could use stat --printf '%n\nmtime: %y\nctime: %z\natime: %x\ncrtime:%w\n' edited Apr 13, 2017 at 12:37 CommunityBot answered Feb 7, 2012 at 15:03 slhck 08********08 #] 11Sep2017 how-to-compare-file-timestamps-in-bash https://superuser.com/questions/138270/how-to-compare-file-timestamps-in-bash The operators for comparing time stamps are: [ $file1 -nt $file2 ] [ $file1 -ot $file2 ] The mnemonic is easy: 'newer than' and 'older than'. answered May 6 '10 at 15:02, Jonathan Leffler >> My example in "/media/bill/HOWELL_BASE/bin/cp-mv general.sh" file1time=`stat -c %Y "$d_src""$line"` file2time=`stat -c %Y "$d_tgt""$line"` if [ $file1time -nt $file2time ]; then echo >>"$p_newDate" "$d_tgt""$line" fi #NAME touch - change file timestamps #SYNOPSIS touch [OPTION]... FILE... #DESCRIPTION # Update the access and modification times of each FILE to the current time. # A FILE argument that does not exist is created empty, unless -c or -h is supplied. # A FILE argument string of - is handled specially and causes touch to change the times of the file associ‐ # ated with standard output. # Mandatory arguments to long options are mandatory for short options too. # -a change only the access time # -c, --no-create # do not create any files # -d, --date=STRING # parse STRING and use it instead of current time # -f (ignored) # -h, --no-dereference # affect each symbolic link instead of any referenced file (useful only on systems that can change the # timestamps of a symlink) # -m change only the modification time # -r, --reference=FILE # use this file's times instead of current time # -t STAMP # use [[CC]YY]MMDDhhmm[.ss] instead of current time # Note that the -d and -t options accept different time-date formats. #DATE STRING # The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 # -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calen‐ # dar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string # indicates the beginning of the day. The date string format is more complex than is easily documented here # but is fully described in the info documentation. # enddoc