How to diff two files side-by-side
Answer:
To diff two files side-by-side, you can try the -y argument.
# diff -y file1.txt file2.txt
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to diff two files side-by-side
Answer:
To diff two files side-by-side, you can try the -y argument.
# diff -y file1.txt file2.txt
How to diff two remote files over ssh?
Answer:
Assume you have two files on two different machine, how do you do a diff of them?
Simply use the command below:
# diff <(ssh server_1 'cat foo1') <(ssh server_2 'cat foo2')
How to ignore blank lines when creating the diff of two files
Answer:
By default, the diff command will also compare the blank line of two files.
To ignore them, use:
# diff -B a.txt b.txt
How to apply a patch?
Answer:
In the last post, you know how to create a patch for two folders.
But, how to use the patch?
See below.
# cp -r foo dummy
# cd dummy
# patch -p1 -i ../bar.patch
Now the folder dummy is the same as bar.
How to create a patch
Answer:
Let say you have two folders, foo and bar.
The folder bar is originally copied from the folder foo, but later you have chanegd some files inside bar.
Now you want to create a patch (We will see later, when this patch applied to foo, it will produce the same contents as in bar).
# diff -crB foo bar > bar.patch