On Tuesday 6 May 2008 21:29, Bob Proulx wrote:

> I can't think of any way to do this natively in bash

Well, there's a loop solution, but it's a bit awkward:

a=help; b=hello; i=0
while [ $i -le $((${#a}-1)) ] && [ $i -le $((${#b}-1)) ]; do
  if [ "${a:${i}:1}" = "${b:${i}:1}" ]; then 
    i=$((i+1))
  else 
    break
  fi
done
echo $((i+1))

-- 
D.

Reply via email to