0

I'm trying to run a simple command on my fish shell, but I am not able to execute. It just keeps adding lines for me to add additional data to, not sure on how to execute accordingly.

$ for acc in `cat uniprot_ids.txt` ; do curl -s "https://www.uniprot.org/uniprot/$acc.fasta" ; done > uniprot_seqs.fasta

enter image description here

2 Answers 2

3

Fish is not bash compatible, but uses its own scripting language.

In this case the only differences are

  1. it doesn't support backticks (```), instead it uses parentheses.
  2. for-loops don't use do/done, instead they just end in "end"

for acc in (cat uniprot_ids.txt); curl -s "https://www.uniprot.org/uniprot/$acc.fasta" ; end > uniprot_seqs.fasta

Also command substitutions only split on newlines, not newlines/spaces/tabs, but I'm betting this has entries on lines anyway. If not, you need to use string split.

4
  • hey thanks! :) I will also try this out and take into consideration but doing as a I mentioned below also worked :D Sep 22, 2020 at 13:08
  • I mean, yeah, it works. But it's a bit of a cop-out, quoting can be annoying and actually learning the shell you're using seems like it would be beneficial
    – faho
    Sep 22, 2020 at 13:52
  • 1
    As a footnote, curl can handle multiple input URLs in a single call, so the for loop can likely be removed in favour of curl -s https://www.uniprot.org/uniprot/(cat uniprot_ids.txt).fasta > uniprot_seqs.fasta
    – CJK
    Sep 23, 2020 at 4:24
  • thank you all :) will take into consideration the advice and comments given Sep 23, 2020 at 8:30
0

This might be quite silly of me, using bash command in front of what I actually want to do made this possible:

bash -c 'for acc in `cat meltome_protein_ids.txt` ; do curl -s "https://www.uniprot.org/uniprot/$acc.fasta"; done > uniprot_seqs.fasta'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .