Every ID is followed by a string(ref_X) followed by a number(every number is referred to the previous ref)
I would like to order the file like this(the column could be more, but always with the same schema- ref_X number-)
If I understand you correctly you wish to maintain the row order of the file then split each record into an ID followed by any number of ref=>value tupples and sort the fields on increasing value...
ETA explanation
To clarify the script above... perl -ne ' use Perl stepping though each line of input and executing the following scriptlet chomp; Strip off any newline character this means none of the strings will have a new line at the end of them ($id,%r)=split; tokenise the string assigning the first token to the $id variable and assign the rest of the tokens in name=> value pairs in %r print $id; print the id for (sort {$r{$a}<=>$r{$b}} keys %r){ step through the name=>value pairs in order of lowest value to highest value print " $_ $r{$_}" print the name value pair out }print"\n"; finally print a new line to replace the one we removed ' tmp.txt end of scriptlet and use tmp.txt as the input
Thank Skrynesaver for the suggestion..I will try it immediately!
Hi RudiC! I am sorry but now I am not able to resolve an issue like that.I have start one month to study awk programming but really...it is very difficult!
However the file should be read like that:
column 1=ID (must be included in the output, in the first column)
column 2 PLUS column 3= the value of these column are associated, meaning that in column 2 there is a name (suppose "ref") and in column 3 there is a number
column 4 PLUS column 5=as above
etc...
What I would like is to reorder the file by maintaining in the first column the ID, and the other column (always paired) should be re-ordered in ascending order.
So