I need to determine the filetype on an indeterminate number of base64-encoded filestreams coming from stdin (image files base64-encoded and cat'ed).
A single file would simply be ... | base64 -d | identify -.
The issue for multiple files is determing the EOF for each file in the stream. Even if I separate the files with \004 before sending them to stdout, the receiving end of the pipe (identify or file, et al) appear not to recognise there is more than one file in the stream (yes, I know the stream is one file, but I was hoping en EOF mid-stream would somehow, for various values of "somehow", work.
I've tried reading stdin in a while read REPLY loop, but read is line-based, not file-based, so appears to not work as I want.
[edit, later] There is between 3-10 files all less than 400KB, so size and processing isn't an issue for my use case, but I'm interested in the question generally.
[eidt, later] I'm trying to avoid tmp files (which is my current solution), mainly because I'm philosophically opposed to using the filesystem as a buffer between two adjacent processes when an inter-process stream is much more efficient. I know that sounds pompous, so for a solution that needs to work right now of course I use tmp files. However, I realised there is a gap in my knowledge and I'm trying to find the answer for the general case.
read's line delimiter?readthem in all at once, or if something smarter should be done.