Concept Flow - diff for file comparison
Start: Two files
Run diff command
Compare lines one by one
Detect differences
Show output with line numbers and change symbols
End
The diff command compares two files line by line and shows where they differ.
diff file1.txt file2.txt
| Step | Action | File1 Line | File2 Line | Difference Detected | Output |
|---|---|---|---|---|---|
| 1 | Read line 1 | Hello world | Hello world | No | |
| 2 | Read line 2 | This is line two | This is line 2 | Yes | 2c2 < This is line two --- > This is line 2 |
| 3 | Read line 3 | End of file | End of file | No | |
| 4 | End of files | Comparison complete |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| line_number | 0 | 1 | 2 | 3 | 3 |
| difference_found | false | false | true | true | true |
| output | "" | "" | 2c2 < This is line two --- > This is line 2 | 2c2 < This is line two --- > This is line 2 | 2c2 < This is line two --- > This is line 2 |
diff command compares two files line by line Shows differences with line numbers and symbols 'c' means changed, 'a' added, 'd' deleted Only differing lines are shown Useful for quick file comparison in terminal