I have the following code:
while ... echo -n "some text" done | while read; do echo "$REPLY" >> file done
but echo works only when used without "-n" flag. looks like when using -n, the output is not flushed/read by next while loop
How can I make sure that "some text" will be read even when not followed by EOL?
You can't distinguish between
echo -n "some text"
echo -n "some t" echo -n "ext"
so you need some kind of delimiting rule. Usually EOL is used for that.
read supports custom delimiter via -d or can split based on number of chars via -n or -N. For example you can make
read fire on each symbol:
echo -n qwe | while read -N 1 ch; do echo $ch; done