I'm absolute new to bash scripting but I have to work with it.
I want to loop through a directory and upload them all to a remote server. Then I have to delete them.
Now the problem I have is following: tcpdump is writing pcap data into this dir (with rotating files), so I don't want to upload the latest file. How can I make sure that when iterating through the dir, that I'll 100-percent skip the latest one? Since the processes for creating the files and uploading them are running parallel, I in the moment I start the upload, there may be a "new" latest file. It wouldn't matter if I would skip uploading of the two newest files, but I don't want to upload the now-latest file.
I tried to learn bash scirpting by reading the solution for "normal" looping, but it's very confusing syntax so I'd be glad if you could help me with a starting point or point me to partial solutions which are understandable for beginners.
PS: The latest file has also the latest timestamp.