Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell scripting newbie needs help

Status
Not open for further replies.

moepower

Programmer
Oct 5, 2000
93
US
Is it possible to find the differences between two files and spool it to a new files?

ie.

File 1 has
line a
line b
line c

File 2 has
line a
line c
line d

I need the result file to have

del line b
add line d

Is this doable?

Thanks,
 


Look at the man page for diff

diff -e ( or is it diff -f ...look at the man page )

will build an ED script of commands to transform file 1 into file 2.

is this what you are lookin for?
 
diff is the way to go.

Here's a solution exactly as asked.

diff "File 1" "File 2" | sed '
/[<>]/{
s/</del/
s/>/add/
b
}
d' Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top