For awk,
Instead of file path can I have variable??
arr=$(awk -v str=start '$2 ~ "^" str "[0-9]*" { print $2; exit; }' /filepath)
Note output was in file path before and now It is in an variable "A". Tried the 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 for more details: Visit Using awk to find a string in a file!
Any help will appreciated.
This worked, thanks anubhava
Use: