Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs

Partner Sites
JustLinux.com
Linux Planet
PHPBuilder
Technology Jobs

Top White Papers

More on LinuxToday


Chaining Linux Commands Together

Feb 03, 2009, 01:32 (0 Talkback[s])

[ Thanks to Brandon for this link. ]

"What if you wanted to run a command and when it finished, run another? Linux provides three ways to do this with a slightly different end result. The semicolon (;), ampersand (&) and the verticle pipe (|) all help the user "chain" commands together.

"[user@localhost ~]$ apt-get update ; apt-get upgrade

"In this example we are using the semicolon (;) to separate these two commands. Using a semicolon tells the shell, "once the first command finishes, run the second one". Once apt-get update finishes, the system will then run it again using the upgrade option.

"[user@localhost ~/project1]$ ./configure && make && make install

"This command is mainly used by developers, software package maintainers and Linux power users. This chain of commands compiles a program and installs it. What the double-ampersands are telling the system is "wait for the first command to successfully complete. If it does complete successfully, run the next command".

Complete Story

Related Stories: