| mvshk@hotmail.com 2007-08-22, 1:22 am |
| Good evening,
I'm struggling to become proficient at scripting, so I apolgize in
advance if this is a glaringly easy question.
I would like to create a script that compares files with the same
prefix (which is the hostname) and uses the oldest as the first and
the most recent as the second. I want to ignore or delete any in
between. Before I use diff/comm, I will grep out the numeric data
(four digit numbers), then show numbers that are only in the most
recent file piped to a text file with the hostname as part of the
name. The input files have the following format: hostname_yyyy-mm-
dd-hh-ss.txt
I would like to process all the files for a particular host in the
directory that that have two files only. Singles would pop an error
message. I have no problem with the grep and compare, what I need
help with is grouping of files and determination of oldest and
newest. I was thinking of a ls with a cut to sort the files, but am
stuck on how to store dates and whole filenames. I have pored over my
scripting and unix books, plus Google with no breakthrough. I plan to
run this in a ksh. Thanks for any help, nw.
|