Question: Having this line

```
Doc=$(awk '/1516001/ { print substr($0,15,11) }' /home/data.txt)  

```

want to change the 1616001 with a variable.

for example:

```
Var='1516001'
Doc=$(awk '/$Var/ { print substr($0,15,11) }' /home/data.txt)  

```

But it doesn't work

Answer: 
@Pedro, in awk a variable's value doesn't work like shell's variable, so we have to assign shell variable's value to an awk's variable and then use it.

```
Doc=$(awk -vvar="$Var" '{if($0 ~ var){print substr($0,15,11)} }' /home/data.txt) 

```

Let me know if this helps you.
You can use `awk -v`

```
Var='1516001'
Doc=$(awk -v pat="$Var" ' $0~pat{ print substr($0,15,11) }' /home/data.txt) 

```