Introduction to IF – BASH programming
Introduction to if General At times you need to specify different courses of action to be taken in a shell script, depending on the success or failure of a command. The if construction allows you to...
View ArticleMore advanced IF usage – BASH programming
More advanced if usage if/then/else constructs Dummy example This is the construct to use to take one course of action if the if commands test true, and another if it tests false. An example: freddy...
View ArticleThe CASE statement – BASH programming
Using case statements Simplified conditions Nested if statements might be nice, but as soon as you are confronted with a couple of different possible actions to take, they tend to confuse. For the more...
View ArticleIntroduction to FUNCTIONS and examples – Bash programming
Introduction to Functions What are functions? Shell functions are a way to group commands for later execution, using a single name for this group, or routine. The name of the routine must be unique...
View ArticleIntroduction to sed – StreamEditor – BASH programming
Introduction to sed What is sed? A Stream EDitor is used to perform basic transformations on text read from a file or a pipe. The result is sent to standard output. The syntax for the sed command has...
View ArticleInteractive editing with SED – BASH programming
Interactive editing with SED Printing lines containing a pattern This is something you can do with grep, of course, but you can’t do a “find and replace” using that command. This is just to get you...
View ArticleNon-interactive editing with SED – BASH programming
Non-interactive editing with SED Reading sed commands from a file Multiple sed commands can be put in a file and executed using the -f option. When creating such a file, make sure that: No trailing...
View ArticleIntroduction to GAWK – BASH programming
Getting started with gawk What is gawk? Gawk is the GNU version of the commonly available UNIX awk program, another popular stream editor. Since the awk program is often just a link to gawk, we will...
View ArticleProgramming with AWK – BASH programming
The print program Printing selected fields The print command in awk outputs selected data from the input file. When awk reads a line of a file, it divides the line in fields based on the specified...
View ArticleGawk variables – BASH programming
Gawk variables As awk is processing the input file, it uses several variables. Some are editable, some are read-only. The input field separator The field separator, which is either a single character...
View ArticleBASH programming – all about redirection
All about redirection Theory and quick reference There are 3 file descriptors, stdin, stdout and stderr (std=standard). Basically you can: redirect stdout to a file redirect stderr to a file redirect...
View ArticleBASH programming – Loops for, while and until
Loops for, while and until In this section you’ll find for, while and until loops. The for loop is a little bit different from other programming languages. Basically, it let’s you iterate over a series...
View Article15 Unix tricks
15 Unix tricks The Unix command line provides numerous ways to make our work easier. Here are 15 “tricks” that I use often to make quick work of various tasks Display the last word in every line of a...
View Article
More Pages to Explore .....