Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional question AWK, awk expert pls help ...

Status
Not open for further replies.

hendnov

Technical User
Feb 27, 2006
73
AU
Hi guys,

I've got the script in awk
Here's part of my script :

I want to add conditional question which in
********************************************************
END {
is this b or a ?
if its a, doing below ...

total = 6*sum
semua = total + jumlah
printf "TOTAL SGML FILES IS = %s \n SPACE FOR SGML : 6 * %s = %s \n\n", sum, sum, total
for(j=0;j<i;++j)print a[j]
printf "TOTAL GRAPHIC FILES = %s \n TOTAL SPACE REQUIRED = %s \n", jumlah, semua

if its b, doing another ...

}
********************************************************

any idea how to do this guys, I know for some of you it seems easy. But not yet for me. THX guys
 
A starting point:
if(some condition){
# some instructions here
}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thx PHV,

But I guess, it's not what I am asking...

I'm looking for conditional question..
how to put it in awk..
and how to get the input value which is the answer from user ...

let's say the question is :
is it A or B ?
so if the answer is A
how to get the input value "A" from user in awk...

Thx guys
 
I have done this in the past by setting a variable called TTY to the tty of the current user, for example

[tt]tty > /tmp/tty.$$
awk -v TTY=`cat /tmp/tty.$$` '
{
...
print "User, please give me some input"
getline < TTY
print "User entered " $0
...
}'
rm /tmp/tty.$$[/tt]

A bit clunky, but it worked.

Annihilannic.
 
Bottom line: have a look at the -v command line option.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
... and why do you need awk exactly?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top