[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: performing diff on parts of a file



On Tue, Jun 15, 2004 at 02:23:11PM -0400, Kamaraju Kusumanchi wrote:
> I am looking for a program/script(?) which performs diff on parts of a 
> file. Say I have a file of 100 lines. How to do diff on lines between 
> 20-30, and 50-60 without writing them into separate files. Which 
> software should I learn for this? sed/awk/perl?
> 
> thanks for any ideas
> raju
> 

Only option I can think about is writing a shell script that will use
head and tail to create temporary files. something like

#!/bin/sh

head -n $2 $1 | tail -n $3 > /tmp/$1.tmp
head -n $5 $4 | tail -n $6 > /tmp/$4.tmp

diff -u /tmp/$1.tmp /tmp/$4.tmp

rm /tmp/$1.tmp /tmp/$4.tmp

> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact 
> listmaster@lists.debian.org
> 
> 
> +++++++++++++++++++++++++++++++++++++++++++
> This Mail Was Scanned By Mail-seCure System
> at the Tel-Aviv University CC.
> 



Reply to: