Edit FASTA header using sed I need to rename the following headers from a FASTA file. Something like:

&gt;ENST00000488147.1::chr1:29570-30013(-)
&gt;ENST00000405392.5::chr2:24919186-24920186(-)


into different format like this:

&gt;chr1:29570-30013(-)_ENST00000488147.1
&gt;chr2:24919186-24920186(-)_ENST00000405392.5


How can I rename the FASTA headers, perhaps using sed or awk?
awk 'BEGIN{FS="::"}{if($1~"&gt;"){printf("&gt;%s_%s\n",$2,substr($1,2))}else{print $0}}' input_file.fa &gt; output.fa


An explanation of the non-obvious bits:


BEGIN{FS="::"} split columns using :: as the designator
$1~"&gt;" If there's a > in the line
substr($1,2) Trim the &gt; that was at the beginning of the line.