Answers.Body: <p>You could try it with <code>sed</code>.<br>
  Replace all lower-case chars with <code>-</code> in lines not starting with <code>&gt;</code>:</p>
  
  <pre><code>sed -e '/^&gt;/!s/[a-z]/-/g' in.fa
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-06T10:30:03.637Z
Answers.LastActivityDate: 2018-11-06T10:57:20.960Z
Answers.LastEditDate: 2018-11-06T10:57:20.960Z
Answers.UserDisplayName: Peter Menzel
Answers.Body: <p>You can also use this solution where <strong>tr</strong> command from linux can solve your problem:</p>
  
  <p><code>tail -n +2  in.fna | tr '[:lower:]' '-'</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-06T12:09:06.477Z
Answers.LastActivityDate: 2018-11-06T12:09:06.477Z
Answers.UserDisplayName: Ammar Sabir Cheema
Answers.Body: <p>The following <code>sed</code> command will do the trick.</p>
  
  <p><code>sed -e '/^[^&gt;]/ s/[a-z]/\-/g' in.fna &gt; out.fna</code></p>
  
  <p>Lines starting with <code>&gt;</code> will be escaped and the lowercase characters will be replaced with <code>-</code> .</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T12:48:23.647Z
Answers.Text: Thaks. I did try to do it without making new copy, but this works.
Answers.UserDisplayName: robinj
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-09T05:31:00.750Z
Answers.Text: you can pipe this to `vcfutils.pl vcf2fq` output.
Answers.UserDisplayName: arup
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-06T10:26:20.770Z
Answers.LastActivityDate: 2018-11-06T10:26:20.770Z
Answers.UserDisplayName: arup
Body: <p>I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase. 
  I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash. 
  I have found simple solution to replace all lowercase to uppercase:</p>
  
  <pre><code>awk 'BEGIN{FS=" "}{if(!/&gt;/){print toupper(<span class="math-container">$0)}else{print $</span>1}}' in.fna &gt; out.fna
  </code></pre>
  
  <p>but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks</p>
  
Tags: <bash><shell>
Title: Replace lowercase characters with -
ThreadText: # Replace lowercase characters with -
  
  (Asked by: username_0 on 2018-11-06)
  
  I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
  I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
  I have found simple solution to replace all lowercase to uppercase:
  
  ```
  awk 'BEGIN{FS=" "}{if(!/>/){print toupper($0)}else{print $1}}' in.fna > out.fna
  
  ```
  
  but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks
  
  **Tags:** bash, shell
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2018-11-06. Score: 4 | Accepted answer
  
  The following `sed` command will do the trick.
  
  `sed -e '/^[^>]/ s/[a-z]/\-/g' in.fna > out.fna`
  
  Lines starting with `>` will be escaped and the lowercase characters will be replaced with `-` .
  
  > **Comments:**
  > **username_0**: Thaks. I did try to do it without making new copy, but this works.  
  > **username_3**: you can pipe this to `vcfutils.pl vcf2fq` output.  
  
  ---
  
  ### Answer by username_1 on 2018-11-06. Score: 3
  
  You could try it with `sed`.  
  Replace all lower-case chars with `-` in lines not starting with `>`:
  
  ```
  sed -e '/^>/!s/[a-z]/-/g' in.fa
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2018-11-06. Score: 1
  
  You can also use this solution where **tr** command from linux can solve your problem:
  
  `tail -n +2 in.fna | tr '[:lower:]' '-'`
  
  
  ---
  
  