Hi,
I’m trying to use “diff” via SSH to show the differences in 2 files. I’m using:
diff file1.html file2.html
…I need to show the line numbers too - and suggestions as to how that can be done?
TIA
Andy
Hi,
I’m trying to use “diff” via SSH to show the differences in 2 files. I’m using:
diff file1.html file2.html
…I need to show the line numbers too - and suggestions as to how that can be done?
TIA
Andy
BTW, heres the example output:
linkssql@undevmac linkssql $ diff test.sh test3.sh
1c1
< mysql -ufoo -pfoo foo;
---
> -ufoo -pfoo foo;
2a3,6
> gdfgdfgdfgdg
>
>
> line 6 added
\\ No newline at end of file
I’m guessing the bits like 2a3,6 mean something in terms of the line numbers? I can’t seem to find anything to advise exactly what they mean though
The files contents are BTW:
test.sh
mysql -ufoo -pfoo foo;
SELECT * FROM test;
test3.sh
-ufoo -pfoo foo;
SELECT * FROM test;
gdfgdfgdfgdg
line 6 added
TIA!
Andy
If you use the ‘-u’ switch with diff, it will output in unified diff format; this is used for patches with the patch program. In this format, the differences are shown as + and - rather than < and >, and before each diff, the line numbers of the offending lines are given.
Hi,
Thanks for the reply.
Ijust tried that:
linkssql@undevmac linkssql $ diff -u test.sh test3.sh
--- test.sh 2006-02-02 08:29:59.000000000 -0800
+++ test3.sh 2008-11-13 04:28:53.000000000 -0800
@@ -1,2 +1,6 @@
-mysql -ufoo -pfoo foo;
+-ufoo -pfoo foo;
SELECT * FROM test;
+gdfgdfgdfgdg
+
+
+line 6 added
\\ No newline at end of file
…is it this bit thats important?
@@ -1,2 +1,6 @@
Not really sure what it means =)
TIA
Andy
Hi,
I’m still battling with this
diff --line-format='%3dn %L' file1.html file2.html
…this prints out like:
1 #!/usr/local/bin/perl
2 # ==================================================================
3 # Bla Bla
3 # Bla Bla Changed This
4 ################################################
5 Something else
(i.e repeats lines that have changed)
…now, this is good -BUT, what I need to do, is try and color code the bits that were taken out (and the bits that were not). i.e make bits red that were taken out - and green for bits that were added. Is there any way to combine the code I have above, and the -u (so it shows + and - or > and < next to lines that were modified)
Anyone got any suggestions?
TIA!
Andy
I’ve heard of a program that you can probably “apt-get install” or similar, called vimdiff. My understanding is it takes similar options to diff, but displays two vim windows side by side with colour coding etc; this might be worth investigating…
Hi,
Thanks for the suggestion Unfortunatly, this needs to be a browser based system (its for comparing new files, to older ones - to see what differences there are)
I ended up getting this in the end:
diff -y --width=250 $CFG->{admin_root_path}/changes/file1.txt $CFG->{admin_root_path}/changes/file2.txt
…which seems to work a charm
Thanks again for taking the time anyway
Cheers
Andy