Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to replace space with underscore using CLI

    Hi,

    I was hoping I could help with 2 scripts to perform similiar functions.

    I have a fasta file that is a combination of all the genome sequences from a specific phylum. I was hoping I could get a script that would replace every space with an underscore.

    For example:

    >Contig 1 Species name strain 1

    >Contig 2 Species name strain 2

    Will be replaces with

    >Contig_1_species_name_strain_1

    >Contig_2_species_name_strain_2

    -------

    Secondly, I was hoping for a script with the same function but will do this for filenames. I have each genome in a seperate fasta file and would like to change the file names to have underscores instead of spaces in the file name.

    Thanks!

  • #2
    1. It is just a command:
    sed 's/ /_/g' input.fa >underscore.fa

    2. The script:
    #!/bin/bash
    mv "$1" `echo $1 | sed 's/ /_/g'`

    The $1 is a special variable for the first argument and ` open a subshell.

    Comment

    Latest Articles

    Collapse

    • seqadmin
      Recent Advances in Sequencing Analysis Tools
      by seqadmin


      The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
      05-06-2024, 07:48 AM
    • seqadmin
      Essential Discoveries and Tools in Epitranscriptomics
      by seqadmin




      The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
      04-22-2024, 07:01 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, Yesterday, 07:03 AM
    0 responses
    14 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-10-2024, 06:35 AM
    0 responses
    36 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-09-2024, 02:46 PM
    0 responses
    43 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 05-07-2024, 06:57 AM
    0 responses
    38 views
    0 likes
    Last Post seqadmin  
    Working...
    X