Saturday, 9 November 2013

Command line diff example

I had to compare some files for changes and used the diff command, thought I would add an example for reference.

File 1:

user@pc:~$ cat test1.txt
aa
aa
aa

File 2:
 user@pc:~$ cat test2.txt
aa
aa
bb
cc
dd
user@pc:~$

 Then the compare:

user@pc:~$ diff -rupN test1.txt test2.txt
--- test1.txt    2013-01-01 22:50:09.918800341 +0000
+++ test2.txt    2013-01-01 22:52:28.214796256 +0000
@@ -1,3 +1,5 @@
 aa
 aa
-aa
+bb
+cc
+dd
user@pc:~$
 Creating a patch file that will contain the difference:

user@pc:~$ diff -rupN test1.txt test2.txt > test3.diff
user@pc:~$ cat test3.diff
--- test1.txt    2013-01-01 22:50:09.918800341 +0000
+++ test2.txt    2013-01-01 22:52:28.214796256 +0000
@@ -1,3 +1,5 @@
 aa
 aa
-aa
+bb
+cc
+dd

Then to patch file 1:
user@pc:~$ patch test1.txt < test3.diff
patching file test1.txt

user@pc:~$ cat test1.txt
aa
aa
bb
cc
dd
user@pc:~$ 

 And if you need to reverse the patch:
user@pc:~$ patch -R test1.txt < test3.diff
patching file test1.txt

user@pc:~$ cat test1.txt
aa
aa
aa
user@pc:~$


Biltong Recipe



Ingredients:   

  • some vinegar
  • less than a table spoon of course salt (or Kosher salt)
  • 1/4 cup of brown sugar
  • 1/2 cup of coriander (whole)(get it at a bulk food store)
  • 1/2 teaspoon pepper (black pepper whole)


The steps for creating biltong:

  • wash the meat
  • cut the meat in strips
  • sprinkle the meat with vinegar
  • use the above biltong mix until the meat strips are well covered
  • place the meat in a tray over night in the fridge (dump any blood that has seeped out of the meat)
  • Hang the meat / biltong
  • Keep the biltong well ventilated and humidity controlled for about 4-7 days