zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[script]判定dd是否成功

是否 成功 script DD 判定
2023-09-14 08:57:47 时间

判定方式

#!/bin/bash

dd if=hello of=hello.c 2> result.dd
retval=`grep "copied" result.dd    | awk '{print $1}'`
filesize=`ls -l ./ | grep 'hello.sh' |awk '{print $5}'`
# echo retval: $retval
# echo filesize: $filesize

if [ $retval -eq $filesize ]; then
echo result: pass
else
echo result: failure
fi

exit 0