HOWTO: String Commands Together Using the Semi-Colon

Posted in Technology
Tue, Apr 11 - 5:25 am EST | 13 years ago by
Comments: 3
Be Sociable, Share!
Use Arrow Keys (← →) to Browse

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.

Use Arrow Keys (← →) to Browse

Be Sociable, Share!

Related Posts

  • Jack

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

  • bartnolten

    what das the ; command do?

  • Pingback: Using Zip And Unzip Via Terminal

Be Sociable, Share!