Issue
I call a library like this:
# myFile.txt is a file that already exists read by `grun`
$ grun TestLexer tokens -tokens myFile.txt
However, instead of passing a file, I'd like to create/re-create that every time I run it in the command-line such as something like the following:
$ grun TestLexer tokens -tokens "echo 'x+1' > myFile.txt"
What would be the proper way to actually do that?
Solution
Bash has process substitution.
You can run a command and make its output available to another command as if it were a file:
$ grun TestLexer tokens -tokens <(echo 'x+1')
To see what is happening, consider:
$ echo <(echo 'x+1')
grun
reads from stdin if a filename is not provided, so you could also pass a here-doc / here-string, or pipe in the data:
$ grun TestLexer tokens -tokens <<<'x+1'
$ echo 'x+1' | grun TestLexer tokens -tokens
Answered By - jhnc Answer Checked By - Cary Denson (WPSolving Admin)