Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Centos5ボックスでこれを実行しました:
ls -al & ; ls -al
ls -al私はそれがバックグラウンドで実行され、同時にフォアグラウンドで実行されることを期待していましls -alた。そうすることで、端末への出力がどのように破壊されるかを示しています。
ls -al
しかし、私は得る:
-bash: 予期しないトークン `;' 付近の構文エラー
これら 2 つのコマンドを同じ行に記述するにはどうすればよいですか?
直感的にはわかりません&が、コマンド セパレーターであり、フォーカーでもあります。つまり、実際には次の 3 つのコマンドがあります。
&
ls -al & ; ls -al # ^^^^^^^|^|^^^^^^^
...そしてBashは空のステートメントをサポートしていません。
代わりに、次のように記述します。
ls -al & ls -al
セミコロンなし。