Fasta is a sequence storage format with ID in first row and sequence (string) in the second row. Row with ID will have ">" at the start.  One of the request is to append increasing number of sequence numbers to the IDs. This is a trivial task if one simply have to append the numbers at the end of header. But user wants it immediately after sequence ID. For eg. if sequence ID line is ">seq1 genus sp", user wants ">seq1_0001 genus sp" for very first one. There are several ways to do it. Let us do it with "nl" function in ubuntu. nl numbers lines and is part of basic utils that come with most of the GNU-linux distros. Let us look at the input and expect output.
input:
=======================================
$ cat test.fas
>seq1 genus sp
acacaca
>seq2 genus sp
acacacg
>seq3 genus sp
acacact
=======================================
Expected output:
=======================================
>seq1_000001 genus sp
acacaca
>seq2_000002 genus sp
acacacg
>seq3_000003 genus sp
acacact
=======================================
code:
=======================================
$ nl -nrz -bp">" test.fas | sed '/>/ s/\([0-9]\+\).*\(>\w\+[0-9]\)\(.*\)/\2_\1\3/g;s/^\s\+//g'
=======================================
nl - number lines
-n - number
-rz - right justified with 0s
-bp - number only those lines with pattern ">"
Now this would add line numbers only at the start. We need to move it to appropriate place using patterns in sed.