Gents
Is it possible to update the code to get the desired output files from the input list. I called variable to the first column.
I need to consider the first column as key to grep the values in the second column according to the desired request.
input list
(attached )
output1
111111 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117,
116,118,124-125,120,122.
232323 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117,
116,118,124-125,120,122-123,126,132.
output2
111111 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117,
111111 116,118,124-125,120,122.
232323 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117,
232323 116,118,124-125,120,122-123,126,132.
Code tried
tp=1
awk '
function printrange() { print start (start == last ? "" : "-" last) }
NR == 1 {start=last=$1; next}
$1 == last+1 {last=$1; next}
{printrange(); start=last=$1}
END {printrange()}
' file | paste -sd" " | fold -sw 60 | tr ' ' ',' | sed 's/^/$tp /'
thanks in advance