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

后端 未结 4 1630
误落风尘
误落风尘 2020-12-15 04:35

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 effi

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 05:22

    Note: zsh only:

    To get a filename containing the contents of ${variable}, use:

    <(<<<${variable})
    

    Note:

    • <<<${variable} redirects STDIN to come from ${variable}
    • <<<${variable} is equivalent to (but faster than) cat <<<${variable}

    So for the OP's case:

    executable -v -i <(<<<${inputData}) -o outputFile.eps
    

提交回复
热议问题