On Tuesday 6 May 2008 07:53, Nathan Coulter wrote:
> Looking for a simple ways to output the byte at which two strings differ.
> Here is one:
>
> cmp <(echo "hello") <(echo "help") | cut -d' ' -f5 | tr -d ,
>
> Any other suggestions?
I can't see how this pertains to gnu.bash.bug, however try this:
echo 'hello help' | sed 's/\([^ ]*\)[^ ]* \1.*/\1/' | wc -m
(this exploits the fact that a newline is appended at the end, so wc sees an
additional character, and gives the expected result).
If the strings can have spaces in them, then use a different separator.
--
D.