-   Programming (
-   -   Assigning variable is messing up (

voldemort 11-05-2010 02:10 PM

Assigning variable is messing up
I am trying to run this and was into issues

function() {
node=echo "" | awk '{split ($0, a, "."); print a[1]}'

function1() {
echo $a
echo $a "- 2nd time"

This output's first a as 10, that's ok but second a as "0", so i was unable to use it anywhere inscript for second time.

I found the actual issue, but I wanna know why is it so

node=`echo "" | awk '{split ($0, a, "."); print a[1]}'`
The above line works, but why?

Can someone please help me

Thank you

paulsm4 11-05-2010 02:26 PM

Oh He-Who-Must-Not-Be-Named: it's called "Command Substitution".

You can use a=`echo "ABC"`.

You can also use the equivalent a=$(echo "ABC").

'Hope that helps!

All times are GMT -5. The time now is 08:30 PM.