BallLightning
BallLightning

Reputation: 23

How can I give a script that reads input from a file input from stdin?

I am working on a project that uses a script (blastn from NCBI's BLAST+ package) that, as far as I can tell, can only read input from a file. I'd like to be able to pass it a string in stdin and have it treat that as if it's the contents of a query file. I could do that by writing the string to a file then giving this script the name of a file but is there a different way to do it that I could try?

Upvotes: 0

Views: 68

Answers (1)

glenn jackman
glenn jackman

Reputation: 247192

2 things come to mind:

  • many tools (but not all) treat the filename - as "read from stdin"

    seq 20 | paste - -
    
  • use a Process Substitution, that looks to the program like a filename

    rev <( echo "hello world" )
    

Upvotes: 2

Related Questions