From 269be007d8cf819f90c804d312969d4451a64679 Mon Sep 17 00:00:00 2001 From: woose Date: Mon, 24 Feb 2025 01:06:58 +0300 Subject: [PATCH] update module1.ipynb --- module1.ipynb | 111 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/module1.ipynb b/module1.ipynb index 7665d18..2291ee3 100644 --- a/module1.ipynb +++ b/module1.ipynb @@ -518,7 +518,116 @@ { "cell_type": "markdown", "metadata": {}, - "source": [] + "source": [ + "# Study guide: diff and patch\n", + "\n", + "## The diff command\n", + "\n", + "You use the diff command to find the differences between two files. On its own, it’s a bit hard to use; instead, use diff -u to find lines that differ in two files:\n", + "\n", + "## Using diff -u\n", + "\n", + "You use the diff -u command to compare two files, line by line, and have the differing lines compared side-by-side in the same output. For an example of what this looks like, see below:\n", + "\n", + "```bash\n", + "~$ cat menu1.txt \n", + "\n", + "Menu1:\n", + "\n", + "Apples\n", + "\n", + "Bananas\n", + "\n", + "Oranges\n", + "\n", + "Pears\n", + "\n", + "~$ cat menu2.txt \n", + "\n", + "Menu:\n", + "\n", + "Apples\n", + "\n", + "Bananas\n", + "\n", + "Grapes\n", + "\n", + "Strawberries\n", + "\n", + "~$ diff \\-u menu1.txt menu2.txt \n", + "\n", + "\\--- menu1.txt   2019\\-12-16 18:46:13.794879924 +0900\n", + "\n", + "+++ menu2.txt   2019\\-12-16 18:46:42.090995670 +0900\n", + "\n", + "@@ \\-1,6 +1,6 @@\n", + "\n", + "\\-Menu1:\n", + "\n", + "+Menu:\n", + "\n", + " Apples\n", + "\n", + " Bananas\n", + "\n", + "\\-Oranges\n", + "\n", + "\\-Pears\n", + "\n", + "+Grapes\n", + "\n", + "+Strawberries\n", + "```\n", + "\n", + "## The patch command\n", + "\n", + "The patch command is useful for applying file differences. See the example below, which compares two files. The comparison is saved as a .diff file, which is then patched to the original file!\n", + "\n", + "```bash\n", + "~$ cat hello\\_world.txt \n", + "\n", + "Hello World\n", + "\n", + "~$ cat hello\\_world\\_long.txt \n", + "\n", + "Hello World\n", + "\n", + "It's a wonderful day!\n", + "\n", + "~$ diff -u hello\\_world.txt hello\\_world\\_long.txt \n", + "\n", + "\\--- hello\\_world.txt     2019-12-16 19:24:12.556102821 +0900\n", + "\n", + "+++ hello\\_world\\_long.txt        2019-12-16 19:24:38.944207773 +0900\n", + "\n", + "@@ -1 +1,3 @@\n", + "\n", + " Hello World\n", + "\n", + "+\n", + "\n", + "+It's a wonderful day!\n", + "\n", + "~$ diff \\-u hello\\_world.txt hello\\_world\\_long.txt > hello\\_world.diff\n", + "\n", + "~$ patch hello\\_world.txt < hello\\_world.diff \n", + "\n", + "patching file hello\\_world.txt\n", + "\n", + "~$ cat hello\\_world.txt \n", + "\n", + "Hello World\n", + "\n", + "It's a wonderful day!\n", + "```\n", + "\n", + "## Resources for more information\n", + "\n", + "There are other interesting patch and diff commands such as patch -p1 and diff -r . For more information on these commands, check out the following resources:\n", + "\n", + "- [http://man7.org/linux/man-pages/man1/diff.1.htmlOpens in a new tab](http://man7.org/linux/man-pages/man1/diff.1.html)\n", + "- [http://man7.org/linux/man-pages/man1/patch.1.htmlOpens in a new tab](http://man7.org/linux/man-pages/man1/patch.1.html)" + ] } ], "metadata": {