Courses/Computer Science/CPSC 457.W2012/FIFO Example

$ echo "hello" > hello.txt $ cat hello.txt hello $ tail -f hello.txt & [1] 3983 $ hello $ echo "goodbye" > hello.txt goodbye $ ps  PID TTY           TIME CMD 3949 ttys006   0:00.03 -bash 3983 ttys006   0:00.00 tail -f hello.txt $

Pipes

$ history | gawk '{print $2}' | head make emacs make emacs make emacs make emacs make ls $ history | gawk '{print $2}' | sort | head PS1="$ bunzip2 bunzip2 cat cd cd cd cd cd cd $ history | gawk '{print $2}' | sort | uniq -c | head  1 PS1="$ 2 bunzip2 1 cat 76 cd 31 clear 3 cp  2 dot 3 echo 29 emacs 20 exit $ history | gawk '{print $2}' | sort | uniq -c | sort -nr | head 100 ls 76 cd  37 ssh 31 clear 29 emacs 21 man 20 exit 19 open 18 more 14 mkdir Named Pipes (FIFOs) Named pipes provide a way of creating an I/O FIFO buffer, represented by a file, that can be referred to by name in other operations, scripts, and programs. The command-line pipes we encountered above are somewhat anonymous; we cannot refer to the pipe at stage three above, for example. It simply exists to pass output from  to

$ mkfifo pipeline $ ls hello.txt	pipeline|	plan.txt	plan.txt~ $ tail -f pipeline & [1] 4153 $ cat hello.txt > pipeline goodbye $ fg tail -f pipeline ^C $ cat hello.txt