Dear Unix experts
Moved from "Shell Programming and Scripting "
I want to define a variable which contains dynmic and static part, daynamic part is the first field.
Sample of data
dddd aaaa sssss 12345
ssss 2323 234234 4242
dddd 3223 34234 54353
ssss 24234 3434 42342
dddd rwrw 423423 werwer
Code:
nawk 'BEGIN {FS=" "}{ $1"_subs"=$1"_subs"+1}END {print dddd_subs}'
it should give me 3
but it gives me error "nawk: syntax error at source line 1
context is
BEGIN {FS=" "}{ >>> $1"_"subs= <<< $1"_"subs+1}
nawk: illegal statement at source line 1"
Can you please help ?
Many thanks in advance
I also tried
Code:
nawk 'BEGIN {FS=" ";diff[$2]=2}{ subs[$1]=+1}END {print subs[dddd], diff [rwrw]}
, Also error...
Can any one advise how to do it in any of the ways above