text: user12272: FASTA files can be very big and unwieldy, especially if lines are at most 80 characters, one can't speed up browsing them by using less with -S to have one sequence every two lines.
  How can I extract just the strain names (or sequence names, i.e. the string on the line starting with >) into a list? I'd like to use seqkit since I'm already familiar with it and know some of the flags and idioms it uses.
  I googled the question but couldn't find an answer using seqkit - the examples all use awk, grep, sed or similar, which are alright for copy/pasting but not very memorable.
  
  user3848: Or a bit more verbose ...
  perl -nle 'push @res, $_  while s/^>//; END {print  join "\n",@res}' myfile.fa
  
  
  user298: You can trivially do this with standard *nix tools. Here are a few options:
  sed -n 's/^>//p' file.fa 
  awk 'sub(/^>/,"")' file.fa
  grep '^>' file.fa | tr -d '>'
  perl -ne 'print if s/^>//' file.fa 
  
  The advantage of these is that they will work on any POSIX-compliant system and most other *nix flavors, even if they're not POSIX such as Linux, out of the box without needing to install any external tools.
  Another thing to take into account is how fast a command is, especially when dealing with large files. I ran a few tests using the solutions presented here on the human hg38 genome assembly which can be downloaded here and seqkit version 2.2.0 which was downloaded from here. The file was stored locally on my laptop's SSD drive, and the laptop itself is:
  $ inxi 
  CPU: quad core Intel Core i7-6820HQ (-MT MCP-)
  speed/min/max: 2896/800/3600 MHz Kernel: 5.17.5-arch1-1 x86_64
  Up: 25d 10h 27m Mem: 15035.9/31958.1 MiB (47.0%)
  Storage: 476.94 GiB (103.1% used) Procs: 452 Shell: Bash inxi: 3.3.15
  
  To get more accurate results, I used a little function I have which will run the command you give it a specified number of times and then report the average real time across all runs. Here's the code if you want to try it:
  timethis(){
      max=$1;
      shift;
  
      for com
      do
          printf '\nCOMMAND: %s\n' "$com"
      c=0;
      while [[ $c -lt $max ]]
      do
        let c++;
        ( time -p eval "$com" ) 2>&1 | grep -oP 'real.*?\K[\d\.]+'
          done | 
          awk -vm=$max '{k+=$1}END{print (k/m)}';
      done
  }
  
  And the results. These are the average "real" (i.e. wall clock) times taken across 10 runs:
  $ timethis 10 \
    "rg '^>' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '>' >/dev/null" \
    "grep '^>' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '>' >/dev/null" \
    "sed -n 's/^>//p' GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null" \
    "perl -ne 'print if s/^>//' GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null" \
    "./seqkit seq -n GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null" \
    "awk 'sub(/^>/,\"\")' GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null" \
    "perl -nle 'push @res, $_  while s/^>//; END {print  join \"\n\",@res}' GCA_000001405.29_GRCh38.p14_genomic.fna"
  
  COMMAND: rg '^>' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '>' >/dev/null
  0.474
  
  COMMAND: grep '^>' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '>' >/dev/null 
  0.583
  
  COMMAND: sed -n 's/^>//p' GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null 
  5.62
  
  COMMAND: perl -ne 'print if s/^>//' GCA_000001405.29_GRCh38.p14_genomic.fna  >/dev/null 
  6.408
  
  COMMAND: ./seqkit seq -n GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null 
  4.326
  
  COMMAND: awk 'sub(/^>/,"")' GCA_000001405.29_GRCh38.p14_genomic.fna >/dev/null 
  13.518
  
  COMMAND: perl -nle 'push @res, 3  while s/^>//; END {print  join "\n",@res}' GCA_000001405.29_GRCh38.p14_genomic.fna 
  8.455
  
  As you can see above, the grep or rg and tr approaches only took around half a second on average, so that is clearly much faster than any of the other choices. However, seqkit is pretty good since it only took around 4 seconds, faster than any of the other ad hoc solutions.
  
  user12272: The nice thing about seqkit is that the answer is really simple and memorable:
  seqkit seq -n sequences.fasta
  
  This will output a text file containing one sequence name per line:
  MPX/PT0001/2022
  MPX/PT0002/2022
  MPX/PT0003/2022
  
  
original_text: 12272: <p>FASTA files can be very big and unwieldy, especially if lines are at most 80 characters, one can't speed up browsing them by using <code>less</code> with <code>-S</code> to have one sequence every two lines.</p>
  <p>How can I extract just the strain names (or sequence names, i.e. the string on the line starting with <code>&gt;</code>) into a list? I'd like to use <code>seqkit</code> since I'm already familiar with it and know some of the flags and idioms it uses.</p>
  <p>I googled the question but couldn't find an answer using seqkit - the examples all use <code>awk</code>, <code>grep</code>, <code>sed</code> or similar, which are alright for copy/pasting but not very memorable.</p>
   3848: <p>Or a bit more verbose ...</p>
  <pre><code>perl -nle 'push @res, $_  while s/^&gt;//; END {print  join &quot;\n&quot;,@res}' myfile.fa
  </code></pre>
   298: <p>You can trivially do this with standard *nix tools. Here are a few options:</p>
  <pre><code>sed -n 's/^&gt;//p' file.fa 
  awk 'sub(/^&gt;/,&quot;&quot;)' file.fa
  grep '^&gt;' file.fa | tr -d '&gt;'
  perl -ne 'print if s/^&gt;//' file.fa 
  </code></pre>
  <p>The advantage of these is that they will work on any POSIX-compliant system and most other *nix flavors, even if they're not POSIX such as Linux, out of the box without needing to install any external tools.</p>
  <p>Another thing to take into account is how fast a command is, especially when dealing with large files. I ran a few tests using the solutions presented here on the human hg38 genome assembly which can be downloaded <a href="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/001/405/GCA_000001405.15_GRCh38/GO_TO_CURRENT_VERSION/GCA_000001405.29_GRCh38.p14_genomic.fna.gz" rel="nofollow noreferrer">here</a> and <code>seqkit</code> version <code>2.2.0</code> which was downloaded from <a href="https://github.com/shenwei356/seqkit/releases/download/v2.2.0/seqkit_linux_amd64.tar.gz" rel="nofollow noreferrer">here</a>. The file was stored locally on my laptop's SSD drive, and the laptop itself is:</p>
  <pre class="lang-sh prettyprint-override"><code>$ inxi 
  CPU: quad core Intel Core i7-6820HQ (-MT MCP-)
  speed/min/max: 2896/800/3600 MHz Kernel: 5.17.5-arch1-1 x86_64
  Up: 25d 10h 27m Mem: 15035.9/31958.1 MiB (47.0%)
  Storage: 476.94 GiB (103.1% used) Procs: 452 Shell: Bash inxi: 3.3.15
  </code></pre>
  <p>To get more accurate results, I used a little function I have which will run the command you give it a specified number of times and then report the average <em>real</em> time across all runs. Here's the code if you want to try it:</p>
  <pre class="lang-sh prettyprint-override"><code>timethis(){
      max=$1;
      shift;
  
      for com
      do
          printf '\nCOMMAND: %s\n' &quot;<span class="math-container">$com"
      c=0;
      while [[ $</span>c -lt <span class="math-container">$max ]]
      do
        let c++;
        ( time -p eval "$</span>com&quot; ) 2&gt;&amp;1 | grep -oP 'real.*?\K[\d\.]+'
          done | 
          awk -vm=<span class="math-container">$max '{k+=$</span>1}END{print (k/m)}';
      done
  }
  </code></pre>
  <p>And the results. These are the average &quot;real&quot; (i.e. wall clock) times taken across 10 runs:</p>
  <pre><code><span class="math-container">$ timethis 10 \
    "rg '^&gt;' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '&gt;' &gt;/dev/null" \
    "grep '^&gt;' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '&gt;' &gt;/dev/null" \
    "sed -n 's/^&gt;//p' GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null" \
    "perl -ne 'print if s/^&gt;//' GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null" \
    "./seqkit seq -n GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null" \
    "awk 'sub(/^&gt;/,\"\")' GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null" \
    "perl -nle 'push @res, $</span>_  while s/^&gt;//; END {print  join \&quot;\n\&quot;,@res}' GCA_000001405.29_GRCh38.p14_genomic.fna&quot;
  
  COMMAND: rg '^&gt;' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '&gt;' &gt;/dev/null
  0.474
  
  COMMAND: grep '^&gt;' GCA_000001405.29_GRCh38.p14_genomic.fna | tr -d '&gt;' &gt;/dev/null 
  0.583
  
  COMMAND: sed -n 's/^&gt;//p' GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null 
  5.62
  
  COMMAND: perl -ne 'print if s/^&gt;//' GCA_000001405.29_GRCh38.p14_genomic.fna  &gt;/dev/null 
  6.408
  
  COMMAND: ./seqkit seq -n GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null 
  4.326
  
  COMMAND: awk 'sub(/^&gt;/,&quot;&quot;)' GCA_000001405.29_GRCh38.p14_genomic.fna &gt;/dev/null 
  13.518
  
  COMMAND: perl -nle 'push @res, 3  while s/^&gt;//; END {print  join &quot;\n&quot;,@res}' GCA_000001405.29_GRCh38.p14_genomic.fna 
  8.455
  </code></pre>
  <p>As you can see above, the <code>grep</code> or <code>rg</code> and <code>tr</code> approaches only took around half a second on average, so that is clearly much faster than any of the other choices. However, <code>seqkit</code> is pretty good since it only took around 4 seconds, faster than any of the other ad hoc solutions.</p>
   12272: <p>The nice thing about <code>seqkit</code> is that the answer is really simple and memorable:</p>
  <pre class="lang-bash prettyprint-override"><code>seqkit seq -n sequences.fasta
  </code></pre>
  <p>This will output a text file containing one sequence name per line:</p>
  <pre><code>MPX/PT0001/2022
  MPX/PT0002/2022
  MPX/PT0003/2022
  </code></pre>
  