* [9fans] diff side-by-side, an rc challange
@ 2017-03-09 15:56 Steve Simon
2017-03-09 20:02 ` Kurt H Maier
0 siblings, 1 reply; 3+ messages in thread
From: Steve Simon @ 2017-03-09 15:56 UTC (permalink / raw)
To: 9fans
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-09 21:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-09 15:56 [9fans] diff side-by-side, an rc challange Steve Simon
2017-03-09 20:02 ` Kurt H Maier
2017-03-09 21:48 ` Steve Simon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).