#] #] ********************* #] "$d_SysMaint"'Linux/[stat, touch] notes.txt' # www.BillHowell.ca 10Oct2023 initial # view in text editor, using constant-width font (eg courier), tabWidth = 3 #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_SysMaint"'Linux/[stat, touch] notes.txt' | sed "s/^#\]/ /" # #24************************24 # Setup, ToDos, #08********08 #] ??Oct2023 #08********08 #] ??Oct2023 #08********08 #] ??Oct2023 #08********08 #] ??Oct2023 #08********08 #] 10Oct2023 touch - still doesn't seem to work in script, terminal comman is OK #] 10Oct2023 timeStamps not working 13:53$ cp "$d_temp"'povrL_pStrP_replace pStrPtmp.txt' "$d_temp"'timeStamped test.txt' ~ 13:53$ ~ 13:54$ stat "$d_temp"'povrL_pStrP_replace pStrPtmp.txt' File: /media/bill/ramdisk/povrL_pStrP_replace pStrPtmp.txt Size: 9943 Blocks: 24 IO Block: 4096 regular file Device: 802h/2050d Inode: 6948738 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-10-10 11:55:36.020587047 -0600 Modify: 2023-10-10 11:55:36.016586986 -0600 Change: 2023-10-10 11:55:36.016586986 -0600 Birth: 2023-10-09 17:03:43.574929104 -0600 ~ 13:54$ stat "$d_temp"'timeStamped test.txt' File: /media/bill/ramdisk/timeStamped test.txt Size: 9943 Blocks: 24 IO Block: 4096 regular file Device: 802h/2050d Inode: 6948739 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-10-10 13:53:40.494338472 -0600 Modify: 2023-10-10 13:53:40.494338472 -0600 Change: 2023-10-10 13:53:40.494338472 -0600 Birth: 2023-10-10 13:53:40.494338472 -0600 13:54$ cp "$d_bin"'0_test/fileops/povr_pStrP_replace/sedChrL legend simple res.txt' "$d_temp"'timeStamped test.txt' ~ 13:58$ stat "$d_temp"'timeStamped test.txt' File: /media/bill/ramdisk/timeStamped test.txt Size: 2284 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 6948739 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-10-10 13:53:40.494338472 -0600 Modify: 2023-10-10 13:58:59.375439182 -0600 Change: 2023-10-10 13:58:59.375439182 -0600 Birth: 2023-10-10 13:53:40.494338472 -0600 13:59$ cp "$d_temp"'timeStamped test.txt' "$d_bin"'0_test/fileops/povr_pStrP_replace/sedChrL legend simple res.txt' ~ 14:00$ stat "$d_bin"'0_test/fileops/povr_pStrP_replace/sedChrL legend simple res.txt' File: /home/bill/web/bin/0_test/fileops/povr_pStrP_replace/sedChrL legend simple res.txt Size: 2284 Blocks: 8 IO Block: 4096 regular file Device: 822h/2082d Inode: 70658845 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-10-10 13:58:59.375439182 -0600 Modify: 2023-10-10 14:00:29.560878334 -0600 Change: 2023-10-10 14:00:29.560878334 -0600 Birth: 2023-08-08 10:53:20.803254325 -0600 timeStamps worked as I normally expected - but not in script? fileops.sh - I removed all "touch" lines +-----+ https://phoenixnap.com/kb/touch-command-in-linux How To Use the touch Command in Linux November 22, 2021 -m Changes the modification time. #08********08 #] 10Oct2023 time [mod, change] - I often need chagne time, not modified see fileops.sh povrL_pStrP_replace() funcFamily +-----+ https://www.howtogeek.com/451022/how-to-use-the-stat-command-on-linux/ How to Use the stat Command on Linux Dave McKay Published Jan 2, 2020 And then we'll use stat to look at the timestamps: >> shows how chmod changes changeTime, but not modTime +-----+ strings.sh I created : pinn_timeChgTo_timeUnix() - for lftp uploads pinn_timeChgTo_yymmddhms() - archive in current dir timeUnix_tests() added : echo 'pStatChg_to_timeUnix : ' pStatChg_to_timeUnix '2023-09-01 13:45:15.388594407 -0600' echo 'pinn_timeChgTo_timeUnix : ' pinn_timeChgTo_timeUnix "$d_web"'home.html' echo 'date_ymdhms_to_timeUnix : ' date_ymdhms_to_timeUnix '230902 9h19m03' created "$d_bin"'strings run.sh' >> oops, have to edit!! I inserted many like : touch -m "$pStrPtmp384" >> Howell : didn't work for povrL_pStrP_replace_test() funcFamily only access time changed, even with -m option remove -m ? +-----+ https://phoenixnap.com/kb/touch-command-in-linux How To Use the touch Command in Linux November 22, 2021 >> access time with touch -a, seems to be same as no option, just touch 10:54$ touch "$d_bin"'0_test/fileops/povrL_pStrP_replace/sedChrL legend simple res.txt' >> this worked directly, didn't work in script? 10:54$ stat "$d_bin"'0_test/fileops/povrL_pStrP_replace/sedChrL legend simple res.txt' File: /home/bill/web/bin/0_test/fileops/povrL_pStrP_replace/sedChrL legend simple res.txt Size: 2284 Blocks: 8 IO Block: 4096 regular file Device: 822h/2082d Inode: 70658865 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ bill) Gid: ( 1000/ bill) Access: 2023-10-10 10:54:41.957132039 -0600 Modify: 2023-10-10 10:54:41.957132039 -0600 Change: 2023-10-10 10:54:41.957132039 -0600 Birth: 2023-08-09 12:23:49.497417801 -0600 >> and nemo dir shows current date-time so why isn't 'fileops test run.sh' working? try again >> nope even for '/sedChrL legend simple res.txt' tDelta=$(( tUnixMod - tUnixBeg )) is negative (small) I'm using the wrong comparison in script touch not working for some reason # enddoc