If you want pipes, you can use them.
The documentation for System.cmd/2 mentions
Shell commands
If you desire to execute a trusted command inside a shell, with pipes, redirecting and so on, please check
:os.cmd/1.
so you can do
iex(11)> :os.cmd('wc -l < foo.txt') |> :binary.list_to_bin()
"5\n"
If you want to read from a variable, you interpolate it, or set an environment variable
iex(14)> System.put_env("foo", "bar baz")
:ok
iex(17)> :os.cmd('echo ${foo}') |> :binary.list_to_bin()
"bar baz\n"
iex(18)> :os.cmd('echo ${foo} | wc') |> :binary.list_to_bin()
" 1 2 8\n"


















