I am currently having some pain reading very small amounts of input from stdin with bash. For example I want to be able to just pull the next byte of stdin (as a string). read wants to pull lines.
I did think of doing something like:
cat - > /tmp/foo cat /tmp/foo | cut -b 42But the problem with this is that stdin of the bash script I am writing never ends. Perhaps I could so something like:
cat - > /tmp/foo & cat /tmp/foo | cut -b 42Then I need to be able to handle the scenario when the reader is ahead of the writing, probably by just spinning until the input appears.
This of course doesn't work as I had expected it to, because the first cat can't be backgrounded because then it looses access to stdin. I need some sort of forking mechanism...
posted at: 00:00 | path: /problemcode | permanent link to this entry
