compare data

Hi,

my problem is, I have to files, one is a log file of an actual execution, the other file is a pattern file.

The entries

"abcd,,!!11.22!!,3asdf" and
"abcd,,!!xx.xx!!,3asdf"

should be identified as equal.
At the position of the x in the pattern file, the log file must have any character or number, but its not important what character or number stands there. The rest of the string must be identical to the string in the pattern file.

Is this possible to check in a unix script???
I tried to do this with sed and diff, but it was not successfull...

Thanx for help

Ben Sky

Hi,

I think you can use awk, spltt your line into 3 parts using the '!!' signs and compare the first and the third part, the second part which can differ will be ignored.

Regards
Alex

Hi

the problem is, that not allways "!!" sings are there this also could be ",./!@#" etc.

Regards
Ben

Hi all,

I solved my problem. I allways searched for "xxx" and compared the part before and the do the same function for the part after the "xxx". Here is my code for this:

function check {

IN_LINE=$1
PAT_LINE=$2

if [ "$IN_LINE" = "$PAT_LINE" ]; then
  return 0
fi


first_pat=`echo "$PAT_LINE" | cut -f 1 -d "xxx"`
length=` echo ${#first_pat}`
first_in=`echo "$IN_LINE" | cut -c 1-$length`

if [ "$first_in" = "$first_pat" ]; then
  length=`expr $length + 4`
  second_pat=`echo "$PAT_LINE" | cut -c ${length}-`
  second_in=`echo "$IN_LINE" | cut -c ${length}-`
  check $second_in $second_pat
  if [ $? -eq 0 ]; then 
    return 0
  fi
else
  echo " Not equal $PAT_LINE and $IN_LINE " 
  return 1
fi

}

Thx

Ben