1. Home
  2. Computing & Technology
  3. Linux

GNU/Linux Command-Line Tools Summary

From


   GNU/Linux Command-Line Tools Summary
   Prev    Chapter 6. Directing Input/Output    Next

6.4. Performing more than one command

  • Executing the second command only if the first is successful
  •    

    To do this you would type:


       

    command1 && command2

    command2 will be executed if command1 successfully completes (if command1 fails command2 won't be run). This is called a logical AND.


  • Executing the second command only if the first fails
  •    

    To do this you would type:


       

    command1 || command2

    command2 will be executed if command1 does not successfully complete (if command1 is successful command2 won't be run). This is called a logical OR.


  • Executing commands sequentially
  •    

    To execute commands sequentially regardless of the success/failure of the previous you simply type:


       

    command1; command2

    command2 will execute once command1 has completed.


           More than two commands
            

    You can continue to use ';' (semicolon) characters to do more and more commands on the one line.



   Prev    Home    Next
   Command Substitution    Up    Working with the file-system


* License

* GNU/Linux Command-Line Tools Summary Index

Explore Linux
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Linux Tools Summary
  6. GNU/Linux Command-Line Tools Summary - Performing more than one command

©2009 About.com, a part of The New York Times Company.

All rights reserved.