This answer shows how to diff
two strings - Using the diff command to compare two strings?
I try:
diff <( printf '%s\n' "tring1" ) <( printf '%s\n' "string2" )
The output is:
1c1
< tring1
---
> string2
This shows that the two strings are different.
I would like to know at which characters the two strings are different, or at least the first character where the difference starts. How can I do it?
This is important when comparing long urls.
I study other answers based on git diff
at diff within a line
I try
git diff --word-diff --word-diff-regex=. <( printf '%s\n' "tring1" ) <( printf '%s\n' "string2" )
The output is:
diff --git a/dev/fd/63 b/dev/fd/62
index 9234a649..b6ce327a 120000
--- a/dev/fd/63
+++ b/dev/fd/62
@@ -1 +1 @@
pipe:[69160538[-6-]{+8+}]
I am not sure if I apply git diff
correctly and how to interpret the output.
git diff
has this functionality then it is better to provide a straitghtforward solution. – Viesturs Nov 16 '21 at 10:52