Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

boolean

Status
Not open for further replies.

krava

Programmer
Jun 4, 2007
48
YU
Hi,


I would like to evaluate $bool bash-variable with help of this awk command

eval $bool=\\$(awk -v str=$bn 'BEGIN{print (match(str,/tau(1|2|3|4|5|6)/) ? 1 : 0)}');

So, when str in awk match this regexp $bool should be 1 (otherwise 0)

Where I make misstake here?

thanks
 
Doesn't this suffice ?
bool=$(awk -v str=$bn 'BEGIN{print (match(str,/tau[1-6]/) ? 1 : 0)}')

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

files that contain for example tau10, tau11 should not give back 1. How to do that?
 
thanks. so your proposition:

bool=$(awk -v str=$bn 'BEGIN{print (match(str,/tau[1-6]/) ? 1 : 0)}')

works but, for files that contain tau10 or tau11, I would like to get 0 as an output. I tried something like this also but does not work

bool=$(awk -v str=$bn 'BEGIN{print (match(str,/tau(1\|2\|3\|4\|5\|6)/) ? 1 : 0)}');
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top