How to combine multiple commands in terminal?

Yes, separate with a semi-colon like so:

dir; ls -l

Most lanugauges/shells use the semi-colon to signify the end of a command and to start new while evaluating from left to right.

Or as @RobieBasak recommends, use && instead of ; to guard against coding accidents.

dir && ls -l

This illustrates more:

  1. A ; B – Run A and then B, regardless of the success or failure of A

  2. A && B – Run B only if A succeeded

  3. A || B – Run B only if A failed

source :https://www.howtogeek.com/269509/how-to-run-two-or-more-terminal-commands-at-once-in-linux/

Tags:

Command Line