q0987
q0987

Reputation: 35982

How to pipe multiple binary files to an application which reads from stdin

For a single file,

$ my_app < file01.binary

For multiple files,

$ cat file*.binary | my_app

Each binary file is of size 500MB and the total size of all file*.binary is around 8GB. Based on my understanding, cat will first concatenate all files then redirect the single big file to my_app.

Is there a better way to send multiple binary files to my_app without first concatenating them?

Upvotes: 3

Views: 1420

Answers (2)

SzG
SzG

Reputation: 12619

No. cat will just read lines/blocks from the input files in a loop and print them to the pipe. No worries.

The "concatenate" in cat means that it concatenates its input to its output. It does not imply that it concatenates its input(s) in memory first.

Upvotes: 2

Senior Pomidor
Senior Pomidor

Reputation: 1915

ls file*.binary | xargs cat | xargs my_app 

xargs is a command to build and execute commands from standard input. It converts input from standard input into arguments to a command.

Upvotes: 1

Related Questions