Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The importance of adding < /dev/null with while loops #49

Open
nickp60 opened this issue Mar 24, 2020 · 0 comments
Open

The importance of adding < /dev/null with while loops #49

nickp60 opened this issue Mar 24, 2020 · 0 comments

Comments

@nickp60
Copy link

nickp60 commented Mar 24, 2020

I've been tricked by this several times, and thought it would be a good addition to the Cookbook. When using while loops without adding the </dev/null after the input the input, only the first line will be processed. Here is the (slightly modified) example from the docs:

  while read org
  do
    esearch -db taxonomy -query "$org [LNGE] AND family [RANK]" < /dev/null |
    efetch -format docsum |
    xtract -pattern DocumentSummary -lbl "$org" \
      -element ScientificName Division
  done <  organisms


(The "< /dev/null" input redirection construct prevents esearch from "draining" the remaining lines from stdin.)

I can make a pull request is this is repo is still being supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant