update module1.ipynb

This commit is contained in:
Yavuz Sava 2025-02-24 01:06:58 +03:00
parent 7ba163ba88
commit 269be007d8

View File

@ -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, its 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.html<svg aria-labelledby=\"cds-react-aria8760104591-:rgs:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria8760104591-:rgs:\"><title id=\"cds-react-aria8760104591-:rgs:-title\">Opens in a new tab</title></svg>](http://man7.org/linux/man-pages/man1/diff.1.html)\n",
"- [http://man7.org/linux/man-pages/man1/patch.1.html<svg aria-labelledby=\"cds-react-aria8760104591-:rgu:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria8760104591-:rgu:\"><title id=\"cds-react-aria8760104591-:rgu:-title\">Opens in a new tab</title></svg>](http://man7.org/linux/man-pages/man1/patch.1.html)"
]
}
],
"metadata": {