![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
Hi
the problem is, that not allways "!!" sings are there this also could be ",./!@#" etc. Regards Ben |
|
#4
|
|||
|
|||
|
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
}
Ben |
|||
| Google The UNIX and Linux Forums |