[nylug-talk] capturing dd time to variable in bash

jh jhlists at hirschman.net
Mon Apr 16 18:33:04 EDT 2007


Chris Knadle wrote:

>>
>> How can I grab this into a variable? Nothing I've tried works :(
> 
> Try:
> 
>       #!/bin/bash
> 
>       export TIMEFORMAT=$'%3R'
>       T_LEN=$(time (dd if=/dev/urandom bs=1024 count=2 \
>                     of=./sillytest > /dev/null 2&>1) 2>&1)
>       echo "time returned: $T_LEN"

Works great. Thanks for preventing me from pulling out my remaining hair :)

jh


More information about the nylug-talk mailing list