有名管道 pipe fifo

两个终端运行,一个输入,一个输出

#!/bin/sh
if [ ! -p /root/mytest/testpipe ]
then
    /bin/mknod /root/mytest/testpipe p
fi

while :
do
    read msg
    if [ "$msg" = "" ]
    then
        continue
    else
        echo "$msg"
    fi
done < /root/mytest/testpipe


#!/bin/sh
tty=`who am i | awk '{print $2}'`
#tty=pts/3
while :
do
    echo "enter your name: \c" >/dev/$tty
    read name
    echo "$name haha"
done > /root/mytest/testpipe


你可能感兴趣的:(shell)