Text pattern with AWK and variables

How to to pass variable to the below awk command
I would like to pass variables to the awk command instead of the constants "a/cc" but I don't know exactly the correct syntax

awk '/a/,/cc/' temp1.out

file.txt

a
b
s
cc
g
d

output

a
b
s
cc

I've tried the following but doesn't make sense!

$ var=a
$ echo $var | awk '/$1/,/cc/' temp1.out
$ awk -v VAR=$var '/$VAR/,/cc/' temp1.out

Please help

VAR=a

awk -v var=$VAR '$0 ~ var,/cc/' temp1.out

# or
awk "/${VAR}/,/cc/" temp1.out

# or
awk '/'${VAR}'/,/cc/' temp1.out
 
va1="a"
va2="cc"
awk  '/'$va1'/,/'$va2'/' input_file

You really want to avoid expanding shell parameters into awk code unless you are absolutely sure that they will not contain any characters that are special to awk. When possible, it's always preferable to use awk's -v option (demonstrated in some of the preceding examples) to pass values into awk from without.

Regards,
Alister

Thnx for the info but I tried all the alternatives but still not working

here is another example

file.txt

cc
f
LST GCELL:
aas
la
laaa

When I tried to get the text pattern between "LST GCELL:" and "la" without using variables it works fine but when using the variables still not working!

# first="LST GCELL:"
# awk '/'$first'/,/la/' file.txt
# awk: syntax error near line 1
# awk: bailing out near line 1

Double quote $first.

I tried but still the same! can you help please

# awk '/"$first"/,/la/' file.txt
#

If you are on Solaris machine then try nawk instead of awk. Else post your server details (shell, machine etc)

first="LST GCELL:"
awk '/'"$first"'/,/la/' file

Use nawk or /usr/xpg4/bin/awk on Solaris.