Home » Shell Scripting

Shell Scripting

Asciidoctor: Creating a macro

I’ve been writing the TWIN4j blog for almost a year now and during that time I’ve written a few different asciidoc macros to avoid repetition. The most recent one I wrote does the formatting around the Featured Community Member of the Week. I call it like this from the asciidoc, passing in the name of the person and a link ...

Read More »

Asciidoc to Asciidoc: Exploding includes

One of my favourite features in AsciiDoc is the ability to include other files, but when using lots of includes is that it becomes difficult to read the whole document unless you convert it to one of the supported backends. $ asciidoctor --help Usage: asciidoctor [OPTION]... FILE... Translate the AsciiDoc source FILE or FILE(s) into the backend output format (e.g., ...

Read More »

Let’s Talk About Shell Scripting

Bash is a command-line shell now available on all major operating systems, and it is the environment from which most developers can accomplish the majority of tasks for a system. Many of the commands that need to be executed to complete a task can be grouped together in a script to help avoid repetition when typing the commands. Furthermore, there’s ...

Read More »

Bash If-Then-Else Example

This is a Bash If-Then-Else Example. Sometimes 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 specify such conditions.                   The following table shows an overview of the whole article: Table ...

Read More »

Bash If – Statement Example

This is an If – Condition Example. Sometimes 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 specify such conditions.                   The most compact syntax of the if command is: if ...

Read More »

Linux Bash awk Example

This is an awk tutorial. The basic function of awk is to search files for lines or other text units containing one or more patterns. When a line matches one of the patterns, special actions are performed on that line. Programs in awk are different from programs in most other languages, because awk programs are “data-driven”. You describe the data ...

Read More »

A Sed (Stream Editor) Example

This is a Sed (Stream Editor) example. 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 no output file specification, but results can be saved to a file using output redirection. The editor does not modify the ...

Read More »

Bash Regular Expressions Example

A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analogously to arithmetic expressions by using various operators to combine smaller expressions.                     The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular ...

Read More »

Bash Environment Variables Tutorial

This is a Bash Environment Variables Tutorial. There exists two types of variables: Global Variables Local Variables Global variables or environment variables are available in all shells. The env or printenv commands can be used to display environment variables. Local variables are only available in the current shell.         Apart from dividing variables in local and global ...

Read More »