LoginSignup
1
0

More than 5 years have passed since last update.

busyboxのshでは |& の表記が使えない

Posted at

メモです。

a.sh
#!/bin/sh
echo stdout
echo stderr >&2

このようにstdoutとstderrの出力するプログラムの両方の出力をpipeに渡したい。

# ./a.sh |& cat > out
-sh: syntax error: unexpected "&"

|& の表記をサポートしていないようだ。
代替方法は以下。

# ./a.sh 2>&1 |cat > out
#

これならエラーにならない。

# cat out
stdout
stderr

出力も想定通り。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0