On Tuesday 6 May 2008 22:33, Dave B wrote:
> while [ $i -le $((${#a}-1)) ] && [ $i -le $((${#b}-1)) ]; do
while [ $i -lt ${#a} ] && [ $i -lt ${#b} ]; do
--
D.
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+
On Tue, May 06, 2008 at 01:29:13PM -0600, Bob Proulx wrote:
> Poor Yorick wrote:
> > Looking for a simple ways to output the index at which two strings
> > differ. Here is one:
> >
> > cmp <(echo "hello") <(echo "help") | cut -d' ' -f5 | tr -d ,
> >
> > Any other suggestions?
You could use subs
Poor Yorick wrote:
> Looking for a simple ways to output the index at which two strings
> differ. Here is one:
>
> cmp <(echo "hello") <(echo "help") | cut -d' ' -f5 | tr -d ,
>
> Any other suggestions?
That seems reasonable to me. Although I tend to use awk and sed for
such things. The conce
Looking for a simple ways to output the index at which two strings differ. Here
is one:
cmp <(echo "hello") <(echo "help") | cut -d' ' -f5 | tr -d ,
Any other suggestions?
--
Yorick