Sunday, 8 September 2013

Comparing the filenames with a integer and reading the filename that is lesser than the integer

Comparing the filenames with a integer and reading the filename that is
lesser than the integer

I'm writing a script to read through a folder and compare the file names
with a variable.
Both the file name and variable have time as strings as their value.
Ed: filename - 131222 variable = 133000
My folder contains a list of files with similar naming convention, in
increasing time order. My variable would fall between any of the two file
names. I need to identify the file which is most likely closer(lesser) to
the variable.
I'm using bash shell scripting.
How can i do this comparison? I'm using a for loop to iteratively read the
filenames in a folder. But i'm clueless on how to do the comparison.

No comments:

Post a Comment