
diff:ai:04717
Как сделать быстро посимвольную разницу двух строк в bash
$ diff <(echo -n 'string1' | grep -o . | tr '
$ ' ' ') <(echo -n 'string2' | grep -o . | tr '
$ ' ' ')
$ ' ' ') <(echo -n 'string2' | grep -o . | tr '
$ ' ' ')
try on your machine
This command uses echo to print each character of the two strings on separate lines, then uses grep to match each character and tr to remove the newline characters. Finally, it uses diff to compare the two resulting strings character by character.
This explanation was created by an AI. In most cases those are correct. But please always be careful and
never run a command you are not sure if it is safe.
Questions that are answered by this command:
- Как сделать быстро посимвольную разницу двух строк в bash?