-1

Hi I am creating a shell script file in that I have stored the input of command in the name variable and that variable is passed to another command as follows

name=`v4l2-sysfs-path -d | grep "video" | awk 'NR==1 { split($0,a,"("); gsub(" |\t","",a[1]); print a[1] }'`
echo $name    
path=`v4l2-sysfs-path -d | awk -F' ' '/"$name"/{ printf prev_f2 };{ prev_f2 = $2 }'`
echo $path

when I print the $path it doesn't show me any output but If I tried following

path=`v4l2-sysfs-path -d | awk -F' ' '/video0/ { printf prev_f2 };{ prev_f2 = $2 }'`
echo $path

it shows me output as pci0000:00/0000:00:1d.7/usb2/2-5: how can I pass the name parameter to path

Alfe
  • 56,346
  • 20
  • 107
  • 159
r15
  • 486
  • 1
  • 8
  • 22

1 Answers1

2

Try

path=`v4l2-sysfs-path -d | awk -F' ' /"$name"/'{ printf prev_f2 };{ prev_f2 = $2 }'`
echo $path
Alfe
  • 56,346
  • 20
  • 107
  • 159