$ cat rachid.sed
/\n/!{/\//!{/./H;d};G}s/([^\n]+)\n+([^\n]+)/\1\t\2\n\1\n/s/\t?(.+\/)(.+)\t\2(-[0-9]+)\n\t?/\1\2\3\n\t//(^\t)|([^\n]\t)/!P;D
$ sed -rf rachid.sed A.txt B.txt > C.txt
sed: file rachid.sed line 1: extra characters after command
$ sed --version
sed (GNU sed) 4.2.2
Either a problem with the script, or more likely something to do with
transmitting characters by email, so when I copy and paste it comes out
different than the script you sent.
BTW, I think it helps immensely when writing a long sed script to break
it up to multiple lines, preferably commented. It's much harder to
understand a long complex script jumbled together on one line. Also, the
error message would be more informative (give a specific line).
Daniel
Post by ionut ***@yahoo.com [sed-users]Hello everyone, I'm (relatively) new to this mailing group and this is my first reply. Although a bit late in providing an answer to the OP, I noticed that although this is a sed group, there was no pure sed answer given.
Below is the script saved to file 'rachid.sed', tested on GNU sed version 4.2.1, but it should work on newer GNU versions as well. The source code could be shorter and less cumbersome, but it does its job as requested.
/\n/!{/\//!{/./H;d};G}s/([^\n]+)\n+([^\n]+)/\1\t\2\n\1\n/s/\t?(.+\/)(.+)\t\2(-[0-9]+)\n\t?/\1\2\3\n\t//(^\t)|([^\n]\t)/!P;D
Run the script as follows, and see the result in the file 'C.txt':sed -rf rachid.sed A.txt B.txt > C.txt
If anyone wants an explanation of how that works, I'll be glad to reply back with one.
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
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.
#yiv8958560964 #yiv8958560964 -- #yiv8958560964ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv8958560964 #yiv8958560964ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv8958560964 #yiv8958560964ygrp-mkp #yiv8958560964hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv8958560964 #yiv8958560964ygrp-mkp #yiv8958560964ads {margin-bottom:10px;}#yiv8958560964 #yiv8958560964ygrp-mkp .yiv8958560964ad {padding:0 0;}#yiv8958560964 #yiv8958560964ygrp-mkp .yiv8958560964ad p {margin:0;}#yiv8958560964 #yiv8958560964ygrp-mkp .yiv8958560964ad a {color:#0000ff;text-decoration:none;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ygrp-lc {font-family:Arial;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ygrp-lc #yiv8958560964hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ygrp-lc .yiv8958560964ad {margin-bottom:10px;padding:0 0;}#yiv895856
0964 #yiv8958560964actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv8958560964 #yiv8958560964activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv8958560964 #yiv8958560964activity span {font-weight:700;}#yiv8958560964 #yiv8958560964activity span:first-child {text-transform:uppercase;}#yiv8958560964 #yiv8958560964activity span a {color:#5085b6;text-decoration:none;}#yiv8958560964 #yiv8958560964activity span span {color:#ff7900;}#yiv8958560964 #yiv8958560964activity span .yiv8958560964underline {text-decoration:underline;}#yiv8958560964 .yiv8958560964attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv8958560964 .yiv8958560964attach div a {text-decoration:none;}#yiv8958560964 .yiv8958560964attach img {border:none;padding-right:5px;}#yiv8958560964 .yiv8958560964attach label {display:block;margin-bottom:5px;}#yiv8958560964 .yiv8958560964attach label a {text-decoration:none;}#yiv8958
560964 blockquote {margin:0 0 0 4px;}#yiv8958560964 .yiv8958560964bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv8958560964 .yiv8958560964bold a {text-decoration:none;}#yiv8958560964 dd.yiv8958560964last p a {font-family:Verdana;font-weight:700;}#yiv8958560964 dd.yiv8958560964last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv8958560964 dd.yiv8958560964last p span.yiv8958560964yshortcuts {margin-right:0;}#yiv8958560964 div.yiv8958560964attach-table div div a {text-decoration:none;}#yiv8958560964 div.yiv8958560964attach-table {width:400px;}#yiv8958560964 div.yiv8958560964file-title a, #yiv8958560964 div.yiv8958560964file-title a:active, #yiv8958560964 div.yiv8958560964file-title a:hover, #yiv8958560964 div.yiv8958560964file-title a:visited {text-decoration:none;}#yiv8958560964 div.yiv8958560964photo-title a, #yiv8958560964 div.yiv8958560964photo-title a:active, #yiv8958560964 div.yiv8958560964photo-title a:hover, #yiv8958560964 div.yiv8958560964photo-
title a:visited {text-decoration:none;}#yiv8958560964 div#yiv8958560964ygrp-mlmsg #yiv8958560964ygrp-msg p a span.yiv8958560964yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv8958560964 .yiv8958560964green {color:#628c2a;}#yiv8958560964 .yiv8958560964MsoNormal {margin:0 0 0 0;}#yiv8958560964 o {font-size:0;}#yiv8958560964 #yiv8958560964photos div {float:left;width:72px;}#yiv8958560964 #yiv8958560964photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv8958560964 #yiv8958560964photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv8958560964 #yiv8958560964reco-category {font-size:77%;}#yiv8958560964 #yiv8958560964reco-desc {font-size:77%;}#yiv8958560964 .yiv8958560964replbq {margin:4px;}#yiv8958560964 #yiv8958560964ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv8958560964 #yiv8958560964ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean,
sans-serif;}#yiv8958560964 #yiv8958560964ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv8958560964 #yiv8958560964ygrp-mlmsg select, #yiv8958560964 input, #yiv8958560964 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv8958560964 #yiv8958560964ygrp-mlmsg pre, #yiv8958560964 code {font:115% monospace;}#yiv8958560964 #yiv8958560964ygrp-mlmsg * {line-height:1.22em;}#yiv8958560964 #yiv8958560964ygrp-mlmsg #yiv8958560964logo {padding-bottom:10px;}#yiv8958560964 #yiv8958560964ygrp-msg p a {font-family:Verdana;}#yiv8958560964 #yiv8958560964ygrp-msg p#yiv8958560964attach-count span {color:#1E66AE;font-weight:700;}#yiv8958560964 #yiv8958560964ygrp-reco #yiv8958560964reco-head {color:#ff7900;font-weight:700;}#yiv8958560964 #yiv8958560964ygrp-reco {margin-bottom:20px;padding:0px;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ov li a {font-size:130%;text-decoration:none;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ov li {font-size:77%;list-style-type:square;p
adding:6px 0;}#yiv8958560964 #yiv8958560964ygrp-sponsor #yiv8958560964ov ul {margin:0;padding:0 0 0 8px;}#yiv8958560964 #yiv8958560964ygrp-text {font-family:Georgia;}#yiv8958560964 #yiv8958560964ygrp-text p {margin:0 0 1em 0;}#yiv8958560964 #yiv8958560964ygrp-text tt {font-size:120%;}#yiv8958560964 #yiv8958560964ygrp-vital ul li:last-child {border-right:none !important;}#yiv8958560964
Post by ionut ***@yahoo.com [sed-users][Non-text portions of this message have been removed]
------------------------------------
------------------------------------