BASH

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 Of Contents 1. Introduction 2. Expressions used with if-then-else ...

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 TEST-COMMANDS; then CONSEQUENT-COMMANDS; fi The TEST-COMMAND list is executed, ...

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 expressions that match themselves. Any metacharacter with special meaning may ...

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 variables, we can also ...

Read More »

Linux Remove User Example

Dealing with users is a task that every systems administrator has to deal with frequently. This example will show you how to delete users in Linux, looking at the two different available commands: The default utility, userdel; and a script that acts as more friendly front-end for the default utility, which is named deluser. For this example, Linux Mint 18 ...

Read More »

Linux Change Hostname Example

The hostname are aliases or labels used to identify easily each device within a network. In Linux desktop versions, is the “computer name” that we are asked to specify during the installation. In this example, we can see how that hostname can be changed. For this example, Linux Mint 18 has been used. 1. What is a hostname? In a ...

Read More »

Linux Find Large Files Example

Having our disk tidy and free of garbage occupies space is something we all want to do, but many times we don’t pay attention at large files that are taking up a considerable amount of space that could be useful for something else. In this example, we will see how to look for large files, just to be aware of ...

Read More »