Edit all the fasta headers using awk
EDIT after OP's update:

Try this Perl one-liner:

perl -pe 'BEGIN { $i = 1 } $i += s{&gt;([^_]+)_.*_}{&gt;RNA${i}#${1}/}' input_file &gt; output_file


Here, the command line flags are:
-e: tells the perl interpreter to look for the code inline, rather than in a file with the script,
-p: loop over the input one line at a time, execute the code in the one-liner for each iteration of the loop, and print the result into STDOUT.
The code has regex replacement (see perlre for more details):
s{&gt;([^_]+)_.*_}{&gt;RNA${i}#${1}/}:
replace an underscore, followed by zero or more occurrences (* quantifier) of any character (.), followed by an underscore, with slash (/).
Keep &gt; and the original header part before the underscore, captured by parens into $1 variable.
Add string RNA${i}, where $i is the counter of the fasta headers. The counter is incremented by 1 when the substitution occurs, that is, when the next header occurs.
The variables are used like so in the substitution: ${i}, ${1} to prevent wrong interpolation.
I am also using s{}{} as delimiters for readability (as in most cases) instead of the default s///.

EXAMPLE:

echo "&gt;LTR_retrotransposon100_Gypsy?\nACGT\n&gt;LTR_retrotransposon10011_ERVK\nTCGA" | perl -pe 'BEGIN { $i = 1 } $i += s{&gt;([^_]+)_.*_}{&gt;RNA${i}#${1}/}'


Prints:

&gt;RNA1#LTR/Gypsy?
ACGT
&gt;RNA2#LTR/ERVK
TCGA