After you edit a file, check what you changed. diff compares two files and writes only the lines that are different.
text
learner@tidepool:~/shop$ diff shop.conf.bak shop.conf
2c2
< closing_time=18:30
---
> closing_time=19:00Read the output
2line in the first filecc = changed2line in the second file
| Line starts with | Means |
|---|---|
< | The line in the first file |
> | The line in the second file |
--- | Separates the two |
The first file is the copy, before the edit. The second file is the file after the edit. So < is the old text and > is the new text.
The letter in the first line tells you what happened:
| Letter | Meaning |
|---|---|
c | Changed |
a | Added to the second file |
d | Deleted from the first file |
No output
If the files have the same text, diff writes nothing.
Copy, edit, compare
1. Copycp shop.conf shop.conf.bak
2. Editnano shop.conf
3. Comparediff shop.conf.bak shop.conf
Each line in the diff output is a change that you made. If you see a change that you did not want, fix it, or copy the old file back.