I have thousands of backup files that are of the general format PICU_XX-YYYYYYYYYYY.Stp, where XX is a number and YYYYYYYYY is a Unix timedate stamp. Searching these files manually is difficult and erroneous when I use the windows file date and time. I want to be able to search for these files by using the unix datetime stamp generated.
Sample File Structure
./PICU_06-1328483198.Stp
./PICU_06-1328580000.Stp
./PICU_06-1329124034.Stp
./PICU_06-1329593129.Stp
./PICU_06-1329868449.Stp
./PICU_06-1329934425.Stp
I am trying to generate a small program that will take an input date/time, convert it to the Unix timedate system, and then find the files that are closest to the date/time.
Date example: 02/18/2012 17:25:29
Location example: 06
The date would convert to 1329607529. The next step would be to find the closest file before and after that time and date stamp. So it would take PICU_06 and find ./PICU_06-1329593129.Stp & ./PICU_06-1329868449.Stp
Start of my code:
echo Please enter LOCATION to search for. EX: 01 13 09A 22
read location
echo thanks
echo --------------------------------------------------
echo Please enter time to search for in MILITARY time. Ex: MM/DD/YYYY HH:MM:SS
read startdatetime
echo thanks
echo --------------------------------------------------
date --date=\'$startdatetime\' +"%s"
As it stands, I can't get the datetime to work within the script to generate the second half of filename to search for.
Some of the errors i get are:
date: extra operand ‘+"%s"’
date: the argument ‘02:34:33'’ lacks a leading '+'; when using an option to specify date(s), any non-option argument must be a format string beginning with '+'