Skip to content

Instantly share code, notes, and snippets.

@eduardoaugustojulio
Created January 29, 2020 13:44
Show Gist options
  • Save eduardoaugustojulio/8651436bf70c89905450150d38429ac5 to your computer and use it in GitHub Desktop.
Save eduardoaugustojulio/8651436bf70c89905450150d38429ac5 to your computer and use it in GitHub Desktop.
named pipes example
#!/bin/bash
pipe="pipe"
if [[ ! -p $pipe ]]; then
mkfifo $pipe
fi
while true
do
if read line <$pipe; then
if [[ "$line" == 'quit' ]]; then
break
fi
echo $line
fi
done
#!/bin/bash
pipe="pipe"
if [[ ! -p $pipe ]]; then
echo "Reader not running"
exit 1
fi
if [[ "$1" ]]; then
echo "$1" >$pipe
else
echo "Hello from $$" >$pipe
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment