Skip to content

Instantly share code, notes, and snippets.

@fernandolopez
Created April 24, 2018 17:03
Show Gist options
  • Save fernandolopez/3c5a6ba91fbb476dfdd656a4f5edef5e to your computer and use it in GitHub Desktop.
Save fernandolopez/3c5a6ba91fbb476dfdd656a4f5edef5e to your computer and use it in GitHub Desktop.
#!/bin/bash
uso() {
echo "Uso: $0 [c|s] nickname" >&2
exit 1
}
if [ $# -ne 2 ]; then
uso
fi
case "$1" in
c)
CMD="nc localhost 8008"
;;
s)
CMD="nc -l -p 8008"
;;
*)
uso
esac
NICK="$2"
while read line; do
echo "$(date -R), "$NICK" says: $line"
done | $CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment