In shell for awk, can I have variable instead of file path? -


for awk,

instead of file path can have variable?? arr=$(awk -v str=start '$2 ~ "^" str "[0-9]*" { print $2; exit; }' /filepath)

note output in file path before , in variable "a". tried following:

  arr=$(awk -v str=start '$2 ~ "^" str "[0-9]*" { print $2; exit; }' ,$a) arr=$(awk -v var="a" str=start '$2 ~ "^" str "[0-9]*" { print $2; exit; }' ,$a) 

doesn't work.

previous post more details: visit using awk find string in file!

any appreciated.

this worked, anubhava

use:

arr=$(echo "$a" | awk -v str=start '$2 ~ "^" str "[0-9]*" { print $2; exit; }') 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -