Not the correct output, works fine via CLI, not inside the script.

Guys,
I need you help please.

The script below is not working correclty for checking via a awk/if statement . Can you tell me what i am doing wrong in the script code "if($1 == "$RETENTION_LEVEL") "

Syntax

RETENTION_LEVEL=`echo $LINE | cut -f2 -d" "`
echo " ============== $RETENTION_LEVEL =============== "
RETENTION_CHECK=`$ADM_CMD/bpretlevel | egrep -v "Retention|Level|---------" | awk '{ if($1 == "$RETENTION_LEVEL") print $0}' | awk '{print $2,$3}'`

Script Ouput

+ RETENTION_LEVEL=8
+ echo ' ============== 8 =============== '
+ /usr/openv/netbackup/bin/admincmd/bpretlevel
+ egrep -v 'Retention|Level|---------'
+ awk '{ if($1 == "$RETENTION_LEVEL") print $0}'
+ awk '{print $2,$3}'
+ RETENTION_CHECK=''

What the output should be

# bpretlevel | egrep -v "Retention|Level|---------" | awk '{ if($1 == "3") print $0}'
    3     1 month        31

pls provide the same input..

RETENTION_LEVEL=8 or 3

# bpretlevel | egrep -v "Retention|Level|---------" | awk '{ if($1 == "3") print $0}'
    3     1 month        31
bpretlevel | egrep -v "Retention|Level|---------" | awk '{ if($1 == "$RETENTION_LEVEL") print $0}'

No ouput when run in the script

The variable $RETENTION_LEVEL can't be handed into awk as it won't be substituted inside the single quotation marks of awk.
You can try something like

RETENTION_CHECK=`$ADM_CMD/bpretlevel | awk -v rl="$RETENTION_LEVEL" '!/Retention|Level|---------/ { if($1 == rl) print $2,$3}'

Also no need to have another awk invoked for printing the whole line 1st and then field 2 and 3. You can print it directly and also have awk do the egrep -v thing.

So far my guess.

Worked a treat many thanks.