On 08Jan2007 05:10, yashpal_ait21 <[EMAIL PROTECTED]> wrote:
| I need some help in shell/awk programming. I want to
| assign some value to a shell variable in awk and print
| that value again in the shell.
Generally, you don't get to do things quite that way.
Every program runs in a self-contained address space,
and communicates with other programs via files (this includes pipes
etc).
So what you need to do is use awk to compute and then print
the result you want. Observse:
| Following is the script i have written, but its not
| working :-
[...]
| JVMMODE=""
| [...]
| while read myLine
| do
| echo $myLine|awk ' {if($0 ~/64/) {$'$JVMMODE'=-d64}} '
| done < $myFile
You want to do something like this:
awkout=`echo $myLine | awk '{if($0 ~/64/) {print "-d64"}}'`
[ -n "$awkout" ] && JVMMODE=$awkout
i.e. use the output of the awk script in a variable.
Also, since you're just looking for a "64" in the file,
you could write this:
JVMMODE=
if grep 64 "$myFile" >/dev/null
then JVMMODE=-d64
fi
instead of your while loop.
Cheers,
--
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/
My venus fly trap is higher up the food chain than I am.
- [EMAIL PROTECTED] (Simon Klyne)
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/