Redirection to network addresses

suggest change

Bash treats some paths as special and can do some network communication by writing to /dev/{udp|tcp}/host/port. Bash cannot setup a listening server, but can initiate a connection, and for TCP can read the results at least.

For example, to send a simple web request one could do:

exec 3</dev/tcp/www.google.com/80
printf 'GET / HTTP/1.0\r\n\r\n' >&3
cat <&3

and the results of www.google.com’s default web page will be printed to stdout.

Similarly

printf 'HI\n' >/dev/udp/192.168.1.1/6666

would send a UDP message containing HI\n to a listener on 192.168.1.1:6666

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents