Command in a variable

i want to copy the command

awk -F "=" '{print $2}'

in a user defined variable for later/multiple use...
Please let me know how to do that..

var=$(...)

Read the man page for your shell and search for Command Substitution.

try something like this

myvar=`awk -F "=" '{print $2}' file`

echo $myvar

Don't encourage someone starting out to use backticks. They're rubbish.

Sorry Scott.

Using back tick will place the output of the command execution in the assigned variable.
i don't want to execute the command at this point in time.
Want the literal copy in the variable.. so that i can execute later

You don't have to apologise! They're just a hard to read, a pain to nest and, some would argue, obsolete.

The $(...) notation is nicer all round.

You can assign that command to a variable and execute it later, but I would recommend using a function.

function myAwk {
  awk '....'
}

And call it whenever you need to:

myAwk

Actually I am also new to shell..so I got something new from you to learn.
Thank you Scott.

That's good idea to have a function for the command.
but i am actually looking at some thing like below

VARIABLE=command | awk -F "=" '{print $2}'

so i plan to put a variable instead of awk command.

Is it better to have a function for myawk in this case?

You should try to be more specific about exactly what you want.

You can have a function:

function myAwk {
  command | awk ...
}

And return the value of that into a variable any time you call it:

VARIABLE=$(myAwk)

Yop this seems to a better option.
I will try this, Thanks!