Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
420 views
in Technique[技术] by (71.8m points)

pipe - using a Bash variable in place of a file as input for an executable

I have an executable that is used in a way such as the following:

executable -v -i inputFile.txt -o outputFile.eps

In order to be more efficient, I want to use a Bash variable in place of the input file. So, I want to do something like the following:

executable -v -i ["${inputData}"] -o outputFile.eps

Here, the square brackets represent some clever code.

Do you know of some trick that would allow me to pipe information into the described executable in this way?

Many thanks for your assistance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use the following construct:

<(command)

So, to have bash create a FIFO with the command as the output for you, instead of your attempted -i ["${inputData}"], you would do:

-i <(echo "$inputData")

Therefore, here is your final total command:

executable -v -i <(echo "$inputData") -o outputFile.eps

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...