    >1 length=424197 depth=1.05x           
    ATGCATGCAGTAGCAGATGCAGAGAGACAGATAG             
    AATAGACAGTAGACGATAGACAGTAGAGATAGAGA              
    ACGATGATGACCCAGTAGATGACAGTAGACAGATG            
    >3 length=322465 depth=0.97x               
    GTACATGGTAGCAGATGCAGAGAGACAGATAGAA      
    AATAGACAGTAGACTATAGACAGTAGAGATAGAGA             
    ATATAHATAHATAHAGATTHATHATACAGTATAGAT         
    >4 length=313463 depth=0.87x             
    CGTAGATCGTAGCAGATGCAGAGAGACAGATAGA          
    AATAGACAGTAGACGATAGACAGTAGAGATAGAGA          
    ATAGCAGTAGCAGTAGCAGATGACAGATGGAGAG         
    >6 length=285776 depth=0.79x               
    ATGCATGCAGTAGCAGATGCAGAGAGACAGATAG           
    AATAGACAGTAGACGATAGACAGTAGAGATAGAGA         
    TGATGACGATGACGATGGGTAGAACACCAGATGG        
    >7 length=281883 depth=0.90x                     
    ATGCATGCAGTAGCAGATGCAGAGAGACAGATAG             
    AATAGACAGTAGACGATAGACAGTAGAGATAGAGA              
    GTACAGTAGACAGTAGACAGAGGGGGAGATAGGA        

    

I have a fasta contig file which is numbered serially but for some reasons i have to remove some contigs , which resulted in gaps in the contig serial no. as shown above i.e. it became from 1,2,3,4,5,etc to 1,3,4,6,7 and so on.                      

So,now i want to rearrange the contigs i.e.                

    1 - 1             
    3 - 2            
    4 - 3            
    6 - 4              
    7 - 5 and so on till 580 (My total contigs)    

          

AND rename them as              

    1 - Contig_0001           
    2 - Contig_0002           
    3 - Contig_0003 and so on till Contig_0580            

I am trying it with awk print f function with increment. But i have not succeeded till now .


Thanks for your valuable time .Can anyone help me in solving this issue.             

Try [seqkit replace](https://bioinf.shenwei.me/seqkit/usage/#replace):

    seqkit replace -p '.+' -r 'Contig_{nr}' --nr-width 4  contigs.fasta -o renamed.fasta

Example: 

    $ echo -ne ">1\nactg\n>3\nACTG\n"
    >1
    actg
    >3
    ACTG
    
    $ echo -ne ">1\nactg\n>3\nACTG\n" \
        | seqkit replace -p '.+' -r 'Contig_{nr}' --nr-width 4
    >Contig_0001
    actg
    >Contig_0002
    ACTG

