I am trying to use printf with a character string that is used within a do loop. The problem is that while in the loop, the printf prints the variable name instead of the value. The do loop calls the variable name from a text file (called device.txt):
while read device
do
cat $device.clean |awk -F '\n' '{ printf ("%s\t%s\t%s\t%s\t%s\n", $device, substr($1,1,6), substr($1,43,5), substr($1,11,18), substr($1,30,10)) }'
done < device.txt
The issue is the first %s in the printf. I want the output to contain the variable name (from device.txt). However, it writes $device.
Thanks, in advance!