Directing awk output to a folder

Dear All

I have a simple bash script that creates a folder ( I called it TEMP) in the current directory.

The question is: how do I direct the output of my awk script into folder TEMP?

Below is my attempt:

 
#!/bin/bash
 
mkdir TEMP
 
echo Enter input file:
read infile
 
awk '{ print > $4 "_" $5 ".txt" }' $infile | TEMP

Thanks in advance.

#!/bin/bash
 
mkdir TEMP
 
echo Enter input file:
read infile
 
awk '{ print > (t "/" $4 "_" $5 ".txt") }' t=TEMP $infile | TEMP

Thanks vgersh99 for your reply.

Your code works but it throws up the following error:

Any suggestion to fixing this?

Thanks again for help so far.

#!/bin/bash
 
mkdir TEMP
 
echo Enter input file:
read infile
 
awk '{ print > (t "/" $4 "_" $5 ".txt") }' t=TEMP $infile 

Many thanks vgersh99,

It works!