Q:

Add numbers to end of every alternate line before bracket

Need to add consecutive number to a specific location of hosts file in linux
awk '0==NR%2{$0} 1' FILE

was trying with awk not able to get around
[tab-edge]
101.55.12.199
[tab-edge]
101.55.12.193
[tab-edge]
101.55.12.194
[tab-edge]
101.55.12.192

expected results
[tab-edge1]
101.55.12.199
[tab-edge2]
101.55.12.193
[tab-edge3]
101.55.12.194
[tab-edge4]
101.55.12.192

A:

Could you please try following.
awk '/\[tab/{sub(/\]$/,++count"&")} 1' Input_file

OR if every line starts from [ where you want to insert numbers and not with [tab then try following.
awk '/^\[/{sub(/\]$/,++count"&")} 1'  Input_file

Or with OP's attempt, in case you want to insert count for odd number lines then try following.
awk 'FNR%2!=0{sub(/\]$/,++count"&")} 1'  Input_file

