From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2ec85ef339faf87a39adc47502968675@quintile.net> From: "Steve Simon" Date: Thu, 9 Mar 2017 15:56:34 +0000 To: 9fans@9fans.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] diff side-by-side, an rc challange Topicbox-Message-UUID: b6d2562a-ead9-11e9-9d60-3106f5b1d025 Hi, I am having to dig through some data files comparing similar results, I really need a side-by-side compare. I believe adiff does this for acme, but I am not an acme-ista so I thought "How hand can it be?". I wrote the script below, but then I thought "I should be able to do this without temporary files" This is where my knowledge of rc(1) fails. How to create two pipes, hold them open, and use them to shuffle bytes. anyone care to take up the challange? -Steve -------------------------------- #!/bin/rc tmp1=/tmp/diffsbs-1.$pid tmp2=/tmp/diffsbs-2.$pid fn sigint { rm -f $tmp1 $tmp2 } fn sighup { rm -f $tmp1 $tmp2 } if(! ~ $#* 2){ echo usage: $0 file1 file2 exit 'usage' } diff -b -a $1 $2 | awk -v 'out1='^$tmp1 -v 'out2='^$tmp2 ' { key = substr($0, 1, 1); txt = substr($0, 2, length($0)-2); if(key == " "){ printf("%-32.32s\n", txt) > out1 printf("%-32.32s\n", txt) > out2 } if(key == "-"){ printf("%-32.32s\n", txt) > out1 printf("%-32.32s\n", "") > out2 } if(key == "+"){ printf("%-32.32s\n", "") > out1 printf("%-32.32s\n", txt) > out2 } }' pr -m -o0 -t -w100 -l0 $tmp1 $tmp2