TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Linux & Opensource > Unix

Notices

Simple diff question

Unix


Reply
 
Thread Tools Display Modes
Old 03-11-2007, 03:33 AM   #1
Lawson English
Guest
 
Posts: n/a
Simple diff question

Very simple question, I hope. If I have two files or source trees, and I
want to have a count of the number of lines of code that have changed
from one to the next version, what is the command string to obtain this
info using diff? Or should I be using another utility instead?

Thanks


Lawson English
  Reply With Quote
Old 04-11-2007, 10:33 PM   #2
elsiddik
Guest
 
Posts: n/a
Re: Simple diff question

On Nov 2, 10:01 pm, Lawson English <> wrote:
> Very simple question, I hope. If I have two files or source trees, and I
> want to have a count of the number of lines of code that have changed
> from one to the next version, what is the command string to obtain this
> info using diff? Or should I be using another utility instead?
>
> Thanks
>
> Lawson English


I dont think you can do that .
you can only use diff as a a tool to compare files that are different.
you can always use nl command to count lines, both command on the same
line <could> give you the result that your looking for but im afriad
it would be very annoying outprint if you have a big file.
i would suggest you write a perl script to do so.


cheers,

zaher el siddik




  Reply With Quote
Old 07-11-2007, 04:31 PM   #3
kkzhou
Guest
 
Posts: n/a
Re: Simple diff question

I think command wc is better:
wc -l filename
but I don't know how to recursively deal with a directory

"elsiddik" <>
??????:1194192898.749934.212540@o38g2000hse.google groups.com...
> On Nov 2, 10:01 pm, Lawson English <> wrote:
>> Very simple question, I hope. If I have two files or source trees, and I
>> want to have a count of the number of lines of code that have changed
>> from one to the next version, what is the command string to obtain this
>> info using diff? Or should I be using another utility instead?
>>
>> Thanks
>>
>> Lawson English

>
> I dont think you can do that .
> you can only use diff as a a tool to compare files that are different.
> you can always use nl command to count lines, both command on the same
> line <could> give you the result that your looking for but im afriad
> it would be very annoying outprint if you have a big file.
> i would suggest you write a perl script to do so.
>
>
> cheers,
>
> zaher el siddik
>
>
>
>



  Reply With Quote
Old 28-11-2007, 03:31 AM   #4
Ed Morton
Guest
 
Posts: n/a
Re: Simple diff question



On 11/2/2007 4:01 PM, Lawson English wrote:
> Very simple question, I hope. If I have two files or source trees, and I
> want to have a count of the number of lines of code that have changed
> from one to the next version, what is the command string to obtain this
> info using diff? Or should I be using another utility instead?


Are you looking for differences between the 2 files of source trees, or
differences between the files listed in the 2 files of source trees?

How do you define a "changed line"? Diff reports every "change" as "added"
and/or "deleted" lines:

$ cat file1
a b c
d e f
g h i

$ cat file2
a b c
d x f
g h i

$ diff file1 file2
2c2
< d e f
---
> d x f


I don't know of any utility that can distinguish those cases where you changed
something within a line from those cases where you deleted a line and then later
inserted a different but possibly similair line. Do you just want the count of
added lines, or both added and deleted separately or something else?

Regards,

Ed.

  Reply With Quote
Reply

Thread Tools
Display Modes



< Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT +5.5. The time now is 04:17 PM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional