Redirection to a file
Well, redirecting the output of a is not what an IPC means, but it can be used as such in an asynchronous way: have one process redirect its output to a file and have another one read from the same file later on; and this can be a way to exchange information between the two processes:
zarrelli:~$ myfile=”myfile.txt” ; touch "$myfile" ; echo "$myfile" > controller ; while read -r line; do tar cvzf $line.tgz $line ; done < controller myfile.txt
In this example, we just stored a filename into a variable. We created the file with touch
, and then stored the filename into the controller
file. Once we had the filename into the controller
file, we had it read line by line and each line was stored into the line
variable. Finally, the content of the line variable is used to zip the file pointed by the myfile
variable:
zarrelli:~$ ls -lah total 20K drwxr-xr-x 2 zarrelli zarrelli 4.0K Apr 10 09:18 . drwxr-xr-x 4 zarrelli zarrelli 4.0K Apr 10 09:17 .. -rw-r--r-- 1 zarrelli zarrelli...