Linux

Code Snippet für ddcode snippet for dd

Today i have an little piece of code
I think , i’m not the only one who burn images on sd card from time to time, but it is strange no to know how long it takes to burn in.
First ok all you need a little extra tool : pv

apt-get install pv

Now copy & paste this code to .bashrc

nano .bashrc

dd()
{
    local dd=$(which dd); [ "$dd" ] || {
        echo "'dd' is not installed!" >&2
        return 1
    }

    local pv=$(which pv); [ "$pv" ] || {
        echo "'pv' is not installed!" >&2
        "$dd" "$@"
        return $?
    }

    local arg arg2 infile
    local -a args
    for arg in "$@"
    do
        arg2=${arg#if=}
        if [ "$arg2" != "$arg" ]
        then
            infile=$arg2
        else
            args[${#args[@]}]=$arg
        fi
    done

    "$pv" -tpreb "$infile" | "$dd" "${args[@]}"
}

Most time dd works only for root , so you have to put the same code in /root/.bashrc too
Found this code somewhere on stackexchange.com