Okay, I think this is possible, but I can't quite figure it out. This is the situation.
A folder contains the log files of all the processes on my robot. The structure looks sort of like this:
$ ls -lrt
total 8
drwxrwxr-x 2 per per 4096 nov 3 12:46 launch01
-rw-rw-r-- 1 per per 0 nov 3 12:47 camera112.log
-rw-rw-r-- 1 per per 0 nov 3 12:47 motors121.log
-rw-rw-r-- 1 per per 0 nov 3 12:47 lidar111.log
drwxrwxr-x 2 per per 4096 nov 3 12:49 launch02
-rw-rw-r-- 1 per per 0 nov 3 12:49 motors122.log
-rw-rw-r-- 1 per per 0 nov 3 12:49 lidar211.log
-rw-rw-r-- 1 per per 0 nov 3 12:49 camera113.log
The files camera112.log
, motors121.log
and lidar111.log
are associated to the logs in folder launch01
. I would like to write a script that gets all the files that belong to a specific launch and tar them into one tarball. Since timestamps can change between slightly by files and the numbers in the files are only nearly related, I think the best way to gather all relevant files is to get all files which are below launch01
(inclusive), up to the next directory in the list (exclusive). The number of files can vary, as can the time stamps and names. What is consistent is the folder, then a bunch of files, then the next folder, then files, etc. Ultimately, I would like to get the latest set of logs easily.
Unsure of the approach here. Any ideas how to go about this?
Clarifications:
- Number of files can vary.
- The exact timestamp is not reliable (as above, the folder
launch01
is different thancamera112.log
) but relative timestamps work fine. For instance, if I could tar all files fromlaunch01
(inclusive) tolaunch02
(exclusive) in the list provided byls -lrt
, that works great.
ls -lrt
command uses the timestamps, so if you can't rely on them ... – AdminBee Nov 03 '21 at 13:00launch01
" presumably you mean "all files that are newer thanlaunch01
"? Above and below have only visual meaning – Chris Davies Nov 03 '21 at 14:32launch01
" - I took that to be referring to the visual of the output ofls -lrt
... so, belowlaunch01/
and abovelaunch02/
("up to the next directory in the list") – Greenonline Nov 03 '21 at 15:25launch<n>
, i.e.camera<n>112.log
, etc.. Also, how sure are you that a log forlaunch01
could never appear afterlaunch02
? Is it logically impossible, w.r.t. thread timings, or whatever? – Greenonline Nov 04 '21 at 02:32