Home > Back-end >  How can I give a script that reads input from a file input from stdin?
How can I give a script that reads input from a file input from stdin?

Time:07-01

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?

CodePudding user response:

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" )
    
  •  Tags:  
  • bash
  • Related