grouping using sed or awk

I have below inside a file.

[server1.domain.com]
11.22.33.44
user1

[server2.domain.com]
11.22.33.55
user2

I need this manipulated as

alias server1.domain.com='ssh user1@11.22.33.44'
alias server2.domain.com='ssh user2@11.22.33.55'

Try:

awk '{print "alias " gensub(/[\[\]]/,"","g",$1) "='\''ssh " $3 "@" $2 "'\''" }' FS='\n' RS= file.txt
1 Like

mirni last ' missing

EDIT:
Its fine Thanks

not on my system. What are you running? And what version of awk?
This will probably work only with GNU awk.
On Solaris use nawk.
This should be more portable:

 cat infile.txt | tr -d '[]'  | awk '{print "alias "  "='\''ssh " $3 "@" $2 "'\''" }' FS='\n' RS=