loop and check

Hi,

We are doing a process manually and i am trying to automate it.

This is the process.

We have a set of files in the directory /temp/d1. the number of files are dynamic.

For ex: if i have 5 files i want to compare the chatacters 45-58 of the last line of the first file with the same characters of the last line of the second file and so on until 5 files. We can ignore the first line of the first file and the last line of the last file.

I started doing it and am stuck, because the file numbers are dynamic.

for file_name in `ls ${INPUT_FILE_NAME}_*`;
do
${file_name}_h = `echo head -1 file_name|cut -c 45-58`;
${file_name}_t = `echo head -1 file_name|cut -c 45-58`;
done

can anyone please help.

sorry there was a mistake:-

it should be:-

if i have 5 files i want to compare the chatacters 45-58 of the last line of the first file with the same characters of the first line of the second file and so on until 5 files. We can ignore the first line of the first file and the last line of the last file.

below script check all the files like *.t in current directory, and then recurisly check the first line of file and last line of another file to check the matching result. May useful for you.

check() {
  a=`cat $1 | head -1`
  b=`cat $2 | tail -1`
  echo $a"  "$b
  if [ "$a" = "$b" ]
  then
     echo $1" --match-- "$2
  else
     echo $1" --mismatch-- "$2
  fi
}
for i in `ls *.t`
do
  for j in `ls *.t`
  do
    if [ $i != $j ]
    then
       check $i $j
    fi
  done
done