News for hackers. Stuff that matters.
Re:Advanced Bash-Scripting Guide (2014) by d0mine on Saturday August 20, 2022 @02:52AM (#32529833)
Nothing stops you from calling bash from Python to combine bash pipelines (onelines) but if you must use Python for some reason, to run `baz` for each line in `foo` & `bar` output:

  from subprocess import Popen, PIPE, run
  
  with Popen('foo', stdout=PIPE) as foo, Popen('bar', stdout=PIPE) as bar:
      for f, b in zip(foo.stdout, bar.stdout):
          run(['baz', f, b])
  
(there is a slight difference in behaviour)

There are no comments on this comment yet.