I want to read a file from a given offset until the end of that file.
I need to retrieve the number of bytes that were read during the process and also to redirect the output of the file elsewhere.
Here is my script:
...some stuff here...
dd if=$file bs=1 skip=$skippedBytes | tee >(wc --bytes > $file.count) >(cat - >> $file.output) | $($exportCommandString $file)
byteCount=$(cat $file.count)
rm $file.count
echo "Number of read bytes: $byteCount"
I would like the "wc --bytes" part to put its returned value inside a variable so I can use it after, without using a file ($file.count).
Something like:
dd if=$file bs=1 skip=$skippedBytes | tee >(byteCount=$(wc --bytes)) >(cat - >> $file.output) | $($exportCommandString $file)
echo "Number of read bytes: $byteCount"
Except that doing this, my script hangs and does not work.
Is it possible to do this and how ?