From: "Steve Simon" <steve@quintile.net>
To: 9fans@9fans.net
Subject: [9fans] diff side-by-side, an rc challange
Date: Thu, 9 Mar 2017 15:56:34 +0000 [thread overview]
Message-ID: <2ec85ef339faf87a39adc47502968675@quintile.net> (raw)
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
next reply other threads:[~2017-03-09 15:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 15:56 Steve Simon [this message]
2017-03-09 20:02 ` Kurt H Maier
2017-03-09 21:48 ` Steve Simon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ec85ef339faf87a39adc47502968675@quintile.net \
--to=steve@quintile.net \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).