kshell variables and awk

Hi,

Is it possible to initialise a shell variable and set it to a value from an awk command?

i.e.

#set myvalue = to the first 8 charachters of the line that begins with 0
myvalue = awk '/^0/ {substr($0,1,8)}' myvaluefile

or even declare a variable, then reinitialise it as part of the awk command, such as:

myvalue="TEST"
awk '/^0/ {$myvalue=substr($0,1,8)}' myvaluefile

I'm new to shell scripting so I'm not even sure if this is possible?

Thanks

Try...

myvalue=$(awk '/^0/ {print substr($0,1,8)}' myvaluefile)

More info: Command Substitution