Rename parameters to help you remember what's going on:
diff <file-to-edit> <file-with-updates1) Rename the file parameters to help you remember what's going on like this:> # Rather than: diff
Rather than:
diff f1 f2 # f1=file 1, and f2=file2
think
diff file-to-edit file-with-updates
The results by default come from f1file-to-edit , with updates from f2file-with-updates
i.e. the results operate on the file-to-edit (file1), applying various updates to it..
Similarity, I find these additional renames helpful to conceptualize the results:
2) Also these command renames might help you think about what is happening:
d stands for delete, but 'remove' is more clearly what happens
a stands for add, ...... but 'insert' is more clearly what happens
Used like this:c stands for change = d + a or 'remove + insert'.
Used like this:
2,4d1 ---4d1 or in general D(s)-d-N ---= delete ('remove') D line(s). Then sync at line N in both.
4a24a2,4 ---or in general N-a-U(s) ---= At line N, add ('insert') update's lineupdate-line(s) U.
Note: Parameters for these two are nearly symmetric; just reversed left to right.
Change= 'remove & insert'.
2,4c54c5,6 ---or in general R(s)-c-U(s) ---= Remove R(s) lines, then insert updated lines U(s) in their place.
For example:
For example:
4a24a2,4 ---means starting at 4, add (insert) updated lines 2-4 (i.e. "2,4" means lines 2, 3 and 4)
2,4d1 ---4d1 means remove lines 2-4 (2, 3 and 4).
2,4c54c5,6 ---means remove lines 2-4 (2, 3 and 4), and insert updated lines 5-6 (5 and 6).
*I know that these are stream editor commands, and designed to be processed by a machine. For example, it really is the ed command add, not insert, but it's more helpful for me to think of insert which is what in the end is being done to the file.
They use stream operations, but I prefer to think in terms of results.*