[QUOTE=Telengard;4296620]I think this does what you want. You should definitely review the code and carefully test it before trusting it. I am no expert and there is most likely a better solution to be found.
Code:
$ gawk --re-interval '{ printf $1 " " ; for ( i = 2 ; i <= NF ; i ++ ) { if ( $i ~ /^[0-9]{16,17}$/ ) { printf $i " " } } printf "\n" }' input.txt
d-1 1234567890123456 2543210987654321 3234567890123456 4543210987654321
d-2 1234567890123456 2543210987654321
d-4 1234567890123456 2543210987654321
d-5
d-6
$
Sweet! Worked great on my 6 line test file. Now going for the big test... will let you know. Thanks a lot.