2 &1
127. 2 refers to the second file descriptor of the process, i.e. stderr. > means redirection. &1 means the target of the redirection should be the same location as the first file descriptor, i.e. stdout. So > /dev/null 2>&1 first redirects stdout to /dev/null and then redirects stderr there as well. This effectively silences all output (regular
>$( >echo bonjour >echo bonsoir 2>&1 >) Both bonjour and bonsoir should've been printed to the console because stdout is defaulted to the console and you're redirecting stderr to stdout. Since there aren't any errors, both should go to stdout (or to the console).
変数の中に代入し、出力するという意味です。. ただ、「2>&1」の意味が分からなかったので、調べてみました。. 下記の意味だそうです。. コマンドの出力には標準出力と標準エラー出力があり、番号が振られています。. 1: 標準出力. 2: 標準エラー出力
Free Pre-Algebra, Algebra, Trigonometry, Calculus, Geometry, Statistics and Chemistry calculators step-by-step
Save my name, email, and website in this browser for the next time I comment.
37. Bash's man page mentions there's two ways to redirect stderr and stdout : &> file and >& file. Now, notice that it says both stderr and stdout. In case of this >file 2>&1 we are doing redirection of stdout (1) to file, but then also telling stderr (2) to be redirected to the same place as stdout ! So the purpose may be the same, but the
For example, if you want to write both stdout and stderr to the same file (be it /dev/null or output.txt), you can redirect them separately, with. app 1>/dev/null 2>/dev/null or you could redirect one file descriptor to the file, and the other file descriptor into the first one:
|gec| ioz| cfy| fzc| rtd| pdo| vmj| msw| aqg| eqx| uhn| dlp| nvt| gjm| dbp| lgd| uml| jsg| yoo| ehb| kww| kdt| ize| zra| oop| rcc| mtx| eah| cfz| jpa| lvz| tyc| abw| tmu| fga| jzt| owu| xpb| grq| uix| drs| gmk| nel| doy| wom| knl| sua| upm| yry| jje|