2007/12/29
標準入力と標準エラーを一緒にリダイレクトしたりパイプする
どうやるんだろうと思って調べたら簡単に見つかったのでメモ。
一緒にリダイレクトするには >& を使う。
% ls notfound > result ls: cannot access notfound: そのようなファイルやディレクトリはありません。 % cat result % ls notfound >& result % cat result ls: cannot access notfound: そのようなファイルやディレクトリはありません。
一緒にパイプするには |& を使う。
% ls notfound | wc -l ls: cannot access notfound: そのようなファイルやディレクトリはありません。 0 % ls notfound |& wc -l 1
シェルはそれなりに勉強してきたつもりなんだけど、これは知らなかった(たぶん記憶から消えてる)。
- Category(s)
- linux
- The URL to Trackback this entry is:
- http://dev.ariel-networks.com/Members/matsuyama/stdin-stderr/tbping
Re:標準入力と標準エラーを一緒にリダイレクトしたりパイプする
Posted by
Anonymous User
at
2008-02-12 22:41
それ csh 系での方法ですね。sh 系だとまた違ってた筈です。日頃は tcsh 使ってるので…。