File a-
aaabaaa
File b-
aaaaaa
Request output sample-
aaa-aaa
*- mean there is a letter missing
How to done this using basic unix command or shellscript or sql or 4gl code? ( need just any 1 )
File a-
aaabaaa
File b-
aaaaaa
Request output sample-
aaa-aaa
*- mean there is a letter missing
How to done this using basic unix command or shellscript or sql or 4gl code? ( need just any 1 )
Something like this should work (file order is very important and this compares first line of first file with first line of second file):
awk '
NR==FNR {
a[NR]=$0
next
}
{
delete ary
delete ary2
x=y=len=i=k=0
x=split($0,ary,"");
y=split(a[FNR],ary2,"");
len=x>y?x:y;
while(len>0) {
if (ary[++i]==ary2[++k]) {
printf ary[i]
}
else
{
printf "-"
i--
}
len--
}
print ""
}' file1 file2
$ cat file1
aaabaaa
abcdefabc
aaabbbccc
$ cat file2
aaaaaa
abcabc
acacacac
aaa-aaa
abc---abc
a-----c--