Skip to content

Instantly share code, notes, and snippets.

@showa-yojyo
Created July 30, 2026 13:19
Show Gist options
  • Select an option

  • Save showa-yojyo/508cd4c1c1c72e8025b6774a42b07427 to your computer and use it in GitHub Desktop.

Select an option

Save showa-yojyo/508cd4c1c1c72e8025b6774a42b07427 to your computer and use it in GitHub Desktop.
A note on process substitution in Bash
author プレハブ小屋 <2386769+showa-yojyo@users.noreply.github.com>
created 2026-07-30
draft true
tags
bash
process substitution
title Bash プロセス置換ノート

Bash プロセス置換ノート

プロセス置換を使用すると、ファイル名が要求されている場所でプロセスの入力や出力を渡すことが可能だ。

構文 意味
<(list) list からの出力をファイルからの入力とする
>(list) ファイルへの出力として list へ入力する

例:

diff <(command1) <(command2)

この記法の利点は、command1command2 の出力を diff に引き渡すためだけに一時ファイルを作成しなくて済むことだ。

  • プロセスリストは非同期で実行される。
  • プロセス置換は可能な限り変数展開、命令置換、算術展開と同時に実行される。

Note

>(command-list) は実用上ほとんど用いられないと考えられる。


以上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment