Unix Shell - file compare script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > August 2007 > file compare script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author file compare script
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.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com