Tag Archives: bash

Bash to Basics: The For Loop

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. Continue reading

Command Line Basics: Cut Fields With awk

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.   Continue reading

Command Line Basics: Redirecting Output

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. Continue reading