Using diff
or com
or whatever you want:
diff <(echo "$string1" ) <(echo "$string2")
Greg’s Bash FAQ: Process Substitution
or with a named pipe
mkfifo ./p
diff - p <<< "$string1" & echo "$string2" > p
Greg’s Bash FAQ: Working with Named Pipes
Named pipe is also known as a FIFO.
The -
on its own is for standard input.
<<<
is a “here string”.
&
is like ;
but puts it in the background