channel="\#mychannel"

#doesnt work
(echo NEW
    echo username
    echo password
    echo .chattr tomb0y +ao
    echo .+chan $channel
    echo .save
    echo .quit)| nc localhost 5555 >/dev/null


#works
(echo NEW
    echo username
    echo password
    echo .chattr tomb0y +ao
    echo .+chan \#mychannel
    echo .save
    echo .quit)| nc localhost 5555 >/dev/null

