function call

hi,

can any one help me to correct this function call.

awk -F "," '{ {first=$1; sec=$2; tro=$3;quat=$4 }
if (tro == "")
{

$3 = search "$file2" "$first" "$file3"
{print $1","$2","$3","$4} }
else
{print $1","$2","$3 $4}}' $file1 > $file

search ()

{

cat $1 | awk -v s="$2" 'BEGIN{
n=""

}
{
if ($0 ~ /FEATURE TESTED /)
{
n=$0
}
if (index($0,s)!=0)
{
if (n!="")
print n
n==""
}
}' | sed 's/$ ###### FEATURE TESTED : "//' | sed 's/"//' | sed 's/ /_/g'> $3

awk '{print $1}' $3

}

file3 countain the variable which i want to print in $3.

Whoa there. Can you please edit your post and add code tags. That is really hard to read.

Here are my questions.

1) What is the input data
2) What is the expected output data
3) What error you face ?

Details Please
Siva

Here is my analysis with your code.
awk -F "," '{ {first=$1; sec=$2; tro=$3;quat=$4 } #--- split data and assign variables
#------------- -F specified , as field seperator
if (tro == "") #------third variable is null
{
$3 = search "$file2" "$first" "$file3" #------- here you are calling function
{print $1","$2","$3","$4} # --- finally print the results -- so search modifies $3
}
else
{ print $1","$2","$3 $4 #---------- directly print the result
}
}'
$file1 > $file

#--------------------------------------------------------------
search ()
{

cat $1 | awk -v s="$2" 'BEGIN{ #------ assign variable s="$first" and $1="$file2"
n=""

                          \}
                          \{
            if \($0 ~ /FEATURE TESTED /\)    \#-------divide the line with spaces and get the first line and check it for FEATURE TES
            \{
                            n=$0
            \}
            if \(index\($0,s\)!=0\)
            \{
                    if \(n!=""\)
                            print n
                            n==""
            \}

}' | sed 's/$ ###### FEATURE TESTED : "//' | sed 's/"//' | sed 's/ //g'> $3 #--- if it exist remove the word FEATURE TESTED and " ,