Please anyone know why this command is not giving me any output? allthe variables are correct but no result.
find . -name "$cdr_type*$DAYZ*.unl*" | xargs zcat | awk -F "|" '{if($14==$tdate && $22==$misdn) print $0}'| head
When I echo the command like this
echo "find . -name $cdr_type*$DAYZ*.unl* | xargs zcat | awk -F | '{if($14==$tdate && $22==$misdn) print $0}'|head"
here is my output:
find . -name mgr*20160928*.unl* | xargs zcat | awk -F | '{if(4==20160928093911 && 2==2348094398953)}'| head
My observation is its showing $4 and $2 instead of $14 and $22
${ cdr_type}
,${DAYZ}
,${14}
and${22}
instead of$cdr_type
,$DAYZ
,$14
and$22
.$14
as expanded by the shell would be the same as${1}4
and if$1
is empty, that would give4
as expected. In there, it looks like there are some$
s that you want to pass untouched toawk
and some for which you want shell variables to be expanded.