双方向パイプは、入力パイプおよび出力パイプの機能を組み合わせたものです。双方向パイプを使用するには、ファイル名のパイプ記号 (|) の後にコマンド名を続ける必要があります。ファイルは、入出力両用ファイルとして開く必要があります。
次に例を示します。
select i-o-file assign to "| cmd /c sort" organization is line sequential. fd i-o-file. 01 i-o-file-record pic x(20). procedure division. open i-o i-o-file write i-o-file-record from "Hello world" write i-o-file-record from all "A" write i-o-file-record from all "Z" write i-o-file-record from x"1a" perform until exit read i-o-file at end exit perform end-read display i-o-file-record end-perform close i-o-file
この例では、プログラムは sort プロセスを起動して、3 行のテキストおよびその後ろのファイルの終わりマーカーをプロセスに渡します。その後に、sort プロセスの標準出力から 3 行すべてを読み込みます。