Bash to Basics: The For Loop

February 14, 2010 by · 2 Comments
Filed under: bash, HowTo, linux, Ubuntu 

Previously I've shown how to use the bash while loop in a bash script. Today I'm going to show how to use another type of do loop in bash: the for loop.

The for loop is a little different from the other looping structures in bash. The other loop structures work by evaluating whether an expression is true or false. The for loop works on lists of values. As long as there are items left in the list, the for loop will execute.

Here's a basic example. Read more

Command Line Basics: Cut Fields With awk

December 15, 2009 by · 1 Comment
Filed under: command line, HowTo, linux, Ubuntu 

There are times when you will want to trim some information from the output of a command. This may be because you want to feed that output into another command. Whatever the reason for wanting to manipulate the output, awk is one of many tools available in GNU/Linux to perform this task.   Read more

Bash to Basics: The While Do Loop

September 13, 2009 by · 4 Comments
Filed under: bash, linux 

The While Do Loop

One of the most common structures in programming is the Do Loop. The version that I'm going to show today is the While Do Loop. The basic structure of the While Do Loop is: while condition A exists, execute the loop. Here's an example program that counts to ten and then exits. Read more

Command Line Basics: Pipelining Output

September 5, 2009 by · 3 Comments
Filed under: bash, command line, HowTo, linux, Ubuntu 

One of the most powerful features of the Linux command line interface, (and other shells that conform to the POSIX standard) is the ability to pipeline output from one command as the input to another. This is done using the vertical bar or pipe character [ | ]. Read more

Command Line Basics: Redirecting Output

August 23, 2009 by · 1 Comment
Filed under: bash, command line, HowTo, linux 

In today's command line basics, I'm going to show you how to redirect output from the bash cli (command line interface). The output of most GNU command line tools is normally sent to the terminal (ie - standard output). There are times when you would like to have the output saved as a file. Now, you could copy the text from the terminal and paste it into a text editor and save it, but there's a better way. Read more

« Previous PageNext Page »