According to https://www.computerhope.com/unix/udiff.htm
The
diff
command analyzes two files and prints the lines that are different.
Can I use the same diff
command to compare two strings?
$ more file*
::::::::::::::
file1.txt
::::::::::::::
hey
::::::::::::::
file2.txt
::::::::::::::
hi
$ diff file1.txt file2.txt
1c1
< hey
---
> hi
Instead of saving the content of hey
and hi
into two different files, can I read it directly?
By the way, there are no files named hey
or hi
in the example below, which is why I get No such file or directory
error messages.
$ diff hey hi
diff: hey: No such file or directory
diff: hi: No such file or directory