I am using awk substr
function to get count of the occurence.
Eg :
cat amexe1_e1_dev_Vaibhav_SLM_6_slmlog.txt | /opt/apigee4/contrib/jq '.destinations[0].message.value' | sed -e 's|"\\||g' |tr -d ' '| sed -e 's|n"||g' | sed -e 's|[\]||g' | awk '{ print substr( $v, 1258 ) }' | grep -o ':'| wc -l
when I execute the below command I get the count as expected i.e 1 which is the actual result.
Now instead of passing 1258 directly , I wrap it inside the variable and then use it like below
POS=1258;
cat amexe1_e1_dev_Vaibhav_SLM_6_slmlog.txt | /opt/apigee4/contrib/jq '.destinations[0].message.value' | sed -e 's|"\\||g' |tr -d ' '| sed -e 's|n"||g' | sed -e 's|[\]||g' | awk '{ print substr( $v, $POS ) }' | grep -o ':'| wc -l
And when used in the command I get the result as 28, which is not expected as expected count is 1.
So what I was able to conclude is POS variable is not getting populated correctly, which should replace its value by 1258.
So the question is: How do I invoke the POS variable inside the command?