[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash Scripting



Greetings all,

I have been trying to create a feature in my backup script that will
scan my backup medium (Zip disk) and retrieve filesize and filename,
sorted by the oldest files first. The command `ls -rst1` seems to
provide just the information I seek. However, I can't seem to get the
info. into a workable variable(s). I've tried using the `cut` command,
but that is too inconsistent. I would like to be able to put the
filesize into one array and the filename into another array ala
`filesize[5] = 12391`, and `filename[5] = backup020401.bz2`. Then I
would do calculations based on the filesize to determine how many files
to delete to free up space for a recently created backup.

I'm wearing out my O'Reilly bash book (which by the way is an excellent
reference, but perhaps a bit too concise for a rank beginner like
myself), and I must surely be overlooking something in the man pages ...
anyway does anyone have a better suggestion on how to make this work
with variable file sizes? I simply want to capture the filesizes and
filenames keeping them mutually dependant, but separate so calculations
can be performed on the filesizes. `cut` does work wonderful if the
filesize is consistent in that it takes up the same number of columns
for an entire directory listing. If I have a 1 KB file and a 1 MB file,
then `cut` goes out the door.  Thank you in advance,

Jason