Hi All,
In the short example below, I've tried various quotes and
escapes with no luck. Is this impossible, or am I
just tired??? I want to put a command inside a variable,
but the command references a variable thaty is not
yet defined. Boy am I rusty on this stuff!
Any info is appreciated...
-Lou V.
#!/bin/ksh
##########################################################
# Is it possible to store a command in a variable, with
# an embedded variable in that command and assign a value
# to the embedded variable LATER, and then execute the
# command?
#
# I want the 'for loop' to literally translate to:
#
# for item in `grep cookies /some/file | cut -d: -f1`
#
##########################################################
command="grep $string /some/file | cut -d: -f1"
# Set $string value a bit later...
string=cookies
for item in `$command`
do
echo $item is the first field in a line that has cookies.
done