3

How do I pass some input to a command line by line (ie. invoke the command for every line)?

xargs does not work because it passes the lines as arguments, not as standard input.

The specific case where this came up was decoding a file whose lines were base64-encoded strings.

8

Can be done with a while loop:

produce | while IFS= read -r line; do echo "$line" | process; done | consume

(for some arbitrary produce, process, consume commands which all use standard input/output) but meh. There has to be a more elegant way of doing it.

1
  • (Semicolon is after line, not after do) – Campa Mar 23 '15 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.