Bash scripting question...

Associate
Joined
29 Mar 2010
Posts
831
Having a little problem with a script... I am trying to send blocks read by dd to shasum, but I want to be able to read the output status of dd before sending the output of shasum to stdout.

I started with:
dd if=./random.dat of=/dev/stdout bs=1024 count=1 skip=$i conv=notrunc 2>/dev/null | shasum -a 1; echo $?

but I am pretty sure that $? is the output status of shasum.

When I changed to:

block=`dd if=./random.dat of=/dev/stdout bs=1024 count=1 skip=$i conv=notrunc 2>/dev/null`
if [ $? -eq 0 ] ; then
echo $block | shasum -a 1
else
echo "Error in block $i"
fi

shasum was returning different values (due to some editing done by echo?).

Anyone have any suggestions?
 
Back
Top Bottom