Piping input and output

I would like to do something as simple as:

grep AA < box.inp > box.out

using run. Is the only way to do this one of the cumbersome options discussed here?

(meaning using pipeline etc?) Or is there a simple alternative? I do not need even to store the output of the command in the section, just run it as an external command.

I think you should indeed use pipeline for that. As the documentation for run says:

Use pipeline to control I/O redirection.

But it’s not that bad?

pipeline("box.inp", `grep AA`, "box.out") |> run
1 Like

That does not work for the command I am actually trying to run (instead of grep), probably because some difference related to how it outputs the data.

What is working is this:

  using Supressor
  output = @capture_out run(pipeline(`cat processed.top`,`plumed partial_tempering $(λ[i+1])`))      
  open("$out/topology.top","w") do io
    write(io, output)  
  end

Maybe someone who understands what this capture does might have any idea of what is going on.

Nobody invented a macro like:

@sh   grep AA < box.inp > box.out

to just call a shell? Given that ; gets one into a shell where that works, seems feasible, isn’t it?

Well you can do run(`bash -c "grep AA < box.inp > box.out"`) :slight_smile:

But can you give more information on what fails with run(pipeline("processed.top", `plumed partial_tempering $(λ[i+1])`, "$out/topology.top")) ?

1 Like

Sure, apparently what was failing was my capacity to read a user guide. :grimacing:

1 Like