I have a file with the following structure:GO:0000001      mitochondrion inheritanceGO:0000002      mitochondrial genome maintenanceGO:0000003      reproductionalt_id: GO:0019952alt_id: GO:0050876GO:0000005      obsolete ribosomal chaperone activityGO:0000006      high-affinity zinc uptake transmembrane transporter activityGO:0000007      low-affinity zinc ion transmembrane transporter activityGO:0000008      obsolete thioredoxinalt_id: GO:0000013GO:0000009      alpha-1,6-mannosyltransferase activityWhere it says alt_id it means that it is an alternative to the previous GO: code.I'd like to add to each alt_id the definition of the previous GO:, that is, I want an output like this:GO:0000001      mitochondrion inheritanceGO:0000002      mitochondrial genome maintenanceGO:0000003      reproductionalt_id: GO:0019952     reproductionalt_id: GO:0050876     reproductionGO:0000005      obsolete ribosomal chaperone activityGO:0000006      high-affinity zinc uptake transmembrane transporter activityGO:0000007      low-affinity zinc ion transmembrane transporter activityGO:0000008      obsolete thioredoxinalt_id: GO:0000013      obsolete thioredoxinGO:0000009      alpha-1,6-mannosyltransferase activityHow can I copy the content of the previous row in the following? I work with Cygwin in a Windows-based environment.
Copy part of the content of the previous row into the following
text processing;cygwin
With awk, not sure if it will work on Cygwin$ awk '{ if(/^alt_id/){$0 = $0 p} else{p = ; for (i=2; i<=NF; i++) p = p $i} } 1' ip.txtGO:0000001      mitochondrion inheritanceGO:0000002      mitochondrial genome maintenanceGO:0000003      reproductionalt_id: GO:0019952  reproductionalt_id: GO:0050876  reproductionGO:0000005      obsolete ribosomal chaperone activityGO:0000006      high-affinity zinc uptake transmembrane transporter activityGO:0000007      low-affinity zinc ion transmembrane transporter activityGO:0000008      obsolete thioredoxinalt_id: GO:0000013  obsolete thioredoxinGO:0000009      alpha-1,6-mannosyltransferase activityFor every line not matching alt_id at start of line, use a variable (p) to save all columns from two onwardsWhen line matches alt_id at start of line, append the contents of p variable to input line contained in $0 variableThe final 1 is short cut to print the contents of $0