I am trying to use the following command to extract a substring from a string :
propertyPath=$(echo $path|awk '{print substr($0,3,$index)}')
However the command does not pick up the value of the $index
variable and therefore does not return a valid substring.
This would work:
propertyPath=$(echo $path|awk '{print substr($0,3,'$index')}')
or
propertyPath=$(echo $path|awk -v index=$index '{print substr($0,3,index)}')