Re: replace

"Jim Hill [email protected] [sed-users]" <[email protected]> Sun, 5 Mar 2017 16:10:28 -0800
Newsgroups gmane.editors.sed.user
Message-ID <CAEE75_3_f9iqFtjgEk3ojst6ofVn8d9CkkjbQnNVgkWk_TBq7w@mail.gmail.com>
This is a join with odd field separators, and it looks like you want
to keep the input sequence, that generally means `cat -n` to go
with the `tr`ing and `sort`ing and `awk`ing:

    join -a2 -12 -23 -o2.1,1.1,2.2,2.3,1.3 \
            <(cat -n A.txt|tr - ' ' | sort -k2,2) \
            <(cat -n B.txt|tr / ' ' | sort -k3,3) \
    | sort -n \
    | awk '{print NF<5? $2"/"$3 : $3"/"$4"-"$5 }'


You could do the `cat`/`tr`s with e.g. `awk -F/ '{print NR,$1,$2}' B.txt`
but it's not clearer or shorter or faster.

This way scales.