Currently have this:
set current=192.168.0.5
set servicehost = `echo $current | awk -F. '{print $4}'`
echo $numberoffields
5
..but would like to reduce # of variables and eliminate echo to have something like this:
set servicehost = `awk -v s="$current" -F. 'BEGIN{print $2}'`
But doesn't work. In a similar vein how to determine NR and NF on variables passed via -v .. if possible. For example how to replace the following:
set string = "hello world"
set numberoffields = `echo $string | awk '{printf("%s\n",NF)}'`
echo $numberoffields
2
..with something like this:
set string = "hello world"
set numberoffields = awk -v s=$string 'BEGIN{printf("%s\n",NF)}'
echo $numberoffields
0
Would be great if it returned 2 somehow