Answers.Body: <p>The URL <a href="https://www.uniprot.org/uniprot/A2Z669.fasta" rel="nofollow noreferrer">https://www.uniprot.org/uniprot/A2Z669.fasta</a> redirects to <a href="https://rest.uniprot.org/uniprotkb/A2Z669.fasta" rel="nofollow noreferrer">https://rest.uniprot.org/uniprotkb/A2Z669.fasta</a>. You can see this if you open it in your browser: clicking on the first link will take you to the address of the second.</p>
  <p>Now, <code>curl</code> <a href="https://unix.stackexchange.com/q/763548/22222">doesn't follow redirects by default</a>, you need the <code>-L</code> option for that (see <code>man curl</code>):</p>
  <blockquote>
  <p>-L, --location</p>
  <p>(HTTP)  If  the  server  reports  that  the requested page has moved to a different location (indicated with a Location:
  header and a 3XX response code), this option makes curl redo the request on the new place. If  used  together  with  -i,
  --include or -I, --head, headers from all requested pages are shown.</p>
  </blockquote>
  <p>So you need <code>-L</code> for <code>curl</code> to work here:</p>
  <pre><code>$ curl -L https://www.uniprot.org/uniprot/A2Z669.fasta
  &gt;sp|A2Z669|CSPLT_ORYSI CASP-like protein 5A2 OS=Oryza sativa subsp. indica OX=39946 GN=OsI_33147 PE=3 SV=1
  MRASRPVVHPVEAPPPAALAVAAAAVAVEAGVGAGGGAAAHGGENAQPRGVRMKDPPGAP
  GTPGGLGLRLVQAFFAAAALAVMASTDDFPSVSAFCYLVAAAILQCLWSLSLAVVDIYAL
  LVKRSLRNPQAVCIFTIGDGITGTLTLGAACASAGITVLIGNDLNICANNHCASFETATA
  MAFISWFALAPSCVLNFWSMASR
  </code></pre>
  <p>Or, alternatively, you can use <code>wget</code> which does follow redirects by default:</p>
  <pre><code>$ wget &quot;https://www.uniprot.org/uniprot/A2Z669.fasta&quot; 
  --2023-12-10 16:21:46--  https://www.uniprot.org/uniprot/A2Z669.fasta
  Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
  Resolving www.uniprot.org (www.uniprot.org)... 193.62.193.81
  Connecting to www.uniprot.org (www.uniprot.org)|193.62.193.81|:443... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: https://rest.uniprot.org/uniprot/A2Z669.fasta [following]
  --2023-12-10 16:21:46--  https://rest.uniprot.org/uniprot/A2Z669.fasta
  Resolving rest.uniprot.org (rest.uniprot.org)... 193.62.193.81
  Connecting to rest.uniprot.org (rest.uniprot.org)|193.62.193.81|:443... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: https://rest.uniprot.org/uniprotkb/A2Z669.fasta [following]
  --2023-12-10 16:21:46--  https://rest.uniprot.org/uniprotkb/A2Z669.fasta
  Reusing existing connection to rest.uniprot.org:443.
  HTTP request sent, awaiting response... 200 OK
  Length: 314 [text/plain]
  Saving to: ‘A2Z669.fasta.1’
  
  A2Z669.fasta             100%[=======================================&gt;]     314  --.-KB/s    in 0s      
  
  2023-12-10 16:21:47 (8.57 MB/s) - ‘A2Z669.fasta.1’ saved [314/314]
  </code></pre>
  <p>That creates a <code>A2Z669.fasta</code> file in the current directory which will contain the sequence.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-12-10T14:23:33.790Z
Answers.LastActivityDate: 2023-12-11T10:52:52.567Z
Answers.LastEditDate: 2023-12-11T10:52:52.567Z
Answers.UserDisplayName: terdon
Body: <p>I am trying to get a protein sequence using this command:</p>
  <pre><code>curl https://www.uniprot.org/uniprot/A2Z669.fasta
  </code></pre>
  <p>But I don't get any output:</p>
  <pre><code>$ curl https://www.uniprot.org/uniprot/A2Z669.fasta
  $ 
  </code></pre>
  <p>And no file is created.</p>
  
Tags: <uniprot>
Title: Fetching uniprot seq using bash command
ThreadText: # Fetching uniprot seq using bash command
  
  (Asked by: username_0 on 2023-12-08)
  
  I am trying to get a protein sequence using this command:
  
  ```
  curl https://www.uniprot.org/uniprot/A2Z669.fasta
  
  ```
  
  But I don't get any output:
  
  ```
  $ curl https://www.uniprot.org/uniprot/A2Z669.fasta
  $ 
  
  ```
  
  And no file is created.
  
  **Tags:** uniprot
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-12-10. Score: 1 | Accepted answer
  
  The URL <https://www.uniprot.org/uniprot/A2Z669.fasta> redirects to <https://rest.uniprot.org/uniprotkb/A2Z669.fasta>. You can see this if you open it in your browser: clicking on the first link will take you to the address of the second.
  
  Now, `curl` [doesn't follow redirects by default](https://unix.stackexchange.com/q/763548/22222), you need the `-L` option for that (see `man curl`):
  
  > -L, --location
  >
  > (HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location:
  > header and a 3XX response code), this option makes curl redo the request on the new place. If used together with -i,
  > --include or -I, --head, headers from all requested pages are shown.
  
  So you need `-L` for `curl` to work here:
  
  ```
  $ curl -L https://www.uniprot.org/uniprot/A2Z669.fasta
  >sp|A2Z669|CSPLT_ORYSI CASP-like protein 5A2 OS=Oryza sativa subsp. indica OX=39946 GN=OsI_33147 PE=3 SV=1
  MRASRPVVHPVEAPPPAALAVAAAAVAVEAGVGAGGGAAAHGGENAQPRGVRMKDPPGAP
  GTPGGLGLRLVQAFFAAAALAVMASTDDFPSVSAFCYLVAAAILQCLWSLSLAVVDIYAL
  LVKRSLRNPQAVCIFTIGDGITGTLTLGAACASAGITVLIGNDLNICANNHCASFETATA
  MAFISWFALAPSCVLNFWSMASR
  
  ```
  
  Or, alternatively, you can use `wget` which does follow redirects by default:
  
  ```
  $ wget "https://www.uniprot.org/uniprot/A2Z669.fasta" 
  --2023-12-10 16:21:46--  https://www.uniprot.org/uniprot/A2Z669.fasta
  Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
  Resolving www.uniprot.org (www.uniprot.org)... 193.62.193.81
  Connecting to www.uniprot.org (www.uniprot.org)|193.62.193.81|:443... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: https://rest.uniprot.org/uniprot/A2Z669.fasta [following]
  --2023-12-10 16:21:46--  https://rest.uniprot.org/uniprot/A2Z669.fasta
  Resolving rest.uniprot.org (rest.uniprot.org)... 193.62.193.81
  Connecting to rest.uniprot.org (rest.uniprot.org)|193.62.193.81|:443... connected.
  HTTP request sent, awaiting response... 301 Moved Permanently
  Location: https://rest.uniprot.org/uniprotkb/A2Z669.fasta [following]
  --2023-12-10 16:21:46--  https://rest.uniprot.org/uniprotkb/A2Z669.fasta
  Reusing existing connection to rest.uniprot.org:443.
  HTTP request sent, awaiting response... 200 OK
  Length: 314 [text/plain]
  Saving to: ‘A2Z669.fasta.1’
  
  A2Z669.fasta             100%[=======================================>]     314  --.-KB/s    in 0s      
  
  2023-12-10 16:21:47 (8.57 MB/s) - ‘A2Z669.fasta.1’ saved [314/314]
  
  ```
  
  That creates a `A2Z669.fasta` file in the current directory which will contain the sequence.
  
  
  ---
  
  