The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[urgent need help]compare data bucci Shell Programming and Scripting 2 02-27-2007 08:27 PM
How to compare two flat files and get changed data jtshashidhar Shell Programming and Scripting 3 01-29-2006 07:26 PM
How to compare data in two flat files and update them? rajus19 Shell Programming and Scripting 3 11-08-2005 08:13 AM
Compare Data in the same file lweegp UNIX for Dummies Questions & Answers 1 10-16-2005 11:32 PM
Compare data files ithomp Shell Programming and Scripting 1 06-15-2004 07:08 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-09-2003
Registered User
 

Join Date: Feb 2002
Posts: 23
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
Forum Sponsor
  #2  
Old 10-09-2003
malcom's Avatar
Registered User
 

Join Date: Jul 2003
Location: Germany
Posts: 78
awk

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
  #3  
Old 10-09-2003
Registered User
 

Join Date: Feb 2002
Posts: 23
Hi

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

Regards
Ben
  #4  
Old 10-10-2003
Registered User
 

Join Date: Feb 2002
Posts: 23
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:

Code:
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
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0