HOWTO: String Commands Together Using the Semi-Colon

Posted in Technology
Tue, Apr 11 - 5:25 am EDT | 9 years ago by
Comments: 3
Share This Post:
  • Facebook
  • StumbleUpon
  • Tumblr
  • Reddit
  • Twitter

I had to make sure that I put the ‘using the semi-colon’ part in the title because there are a variety of ways to string commands together in GNU/Linux. Some are more powerful than others (like using the pipe | symbol) and some are just convenient.

The semi-colon operator is more of a convenience than anything really powerful. The semi-colon doesn’t perform any function, it just takes the place of hitting the enter key between commands.

Try this:

mkdir temp; cd temp; ls -all

As you can likely figure out, this will make a directory named temp in the current directory, change to the new directory and then list its contents (yes, it’s new so it will be empty).

You can also run applications and carry on with instructions as the terminate. For example:

nano foo; cd /

Assuming you have the nano editor installed, this will fire it up with the foo file loaded (or blank if you have no foo file). Once you’re done editing and save or otherwise exit nano, you will be taken to the / root directory.

These are two pretty lame-O examples, but they get the point across. Stringing commands together is likely more useful in scripting than in every day life. If you have a decent imagination, it’s easy to see how you can use the semi-colon operator in conjunction with command substitution to build a pretty powerful sequence of events.

Latest Posts

Share This Post:
  • Facebook
  • StumbleUpon
  • Tumblr
  • Reddit
  • Twitter
  • Jack

    This was exactly what I wanted, no extra stuff except what I wanted
    Thanks
    Jack

  • bartnolten

    what das the ; command do?

  • Pingback: Using Zip And Unzip Via Terminal