The tr command stands for the translate characters command. It is used for replacing and deleting characters. The tr command operates on standard input and the results are provided to the standard output. There are several options available in the tr command, we will look at some of them with examples in this section. tr command to convert uppercase to lowercase One of the most common uses of the tr command is converting characters from upper to lowercase and vice versa....
Bash if Else Elif
Introduction A simple bash may only perform some sequential operations to provide the desired outcome. However, many times, we need scripts that perform some kind of logic control flow. For example, executing a certain command only when a specific condition is met. In this section, we will look into some of the conditional statements that bash provides us to perform such operations with examples. Bash if statement Let us first look at the basic if command in bash scripting....
22 Useful Ruby String Methods every ruby programmer should know
Ruby programming language comes with a lot of handy string methods. In this section, we will look at some of them with examples. 1. gsub The gsub method in ruby is used for string replacement. It replaces all the matching patterns with another string. > str = "My favourite character is Mickey. I just love the way Mickey sings." => "My favourite character is Mickey. I just love the way Mickey sings....
Using include <iostream> in C++
What is include <iostream> in C++? If you are new to the C++ programming language, you may have noticed the very first line of C++ code contains the code include<iostream>. In this section, we will look at what the statement include<iostream> does and why we should use it. iostream iostream - stands for input/output stream. iostream is a header file that contains a set of functions for standard input and standard output....
Test Command in Linux
What is test command in Linux? The test command is used to test a given expression that returns an exit status True or False. There are two ways of declaring the test command, first one is using the keyword test and the second is using the square brackets []. test expression [ expression ] The expression gets evaluated as either true or false. If the test command returns an exit status as 0 then the expression is true....
Wildcards in Linux with examples
Introduction The Linux shell comes with a very handy feature called the wildcards which uses special characters to match patterns of characters. This allows us to search and list filenames easily. In this section, we will look into some of the special characters used as wildcards and also learn how they can help us save time with examples. ‘*’ wildcard The asterisk(*) matches zero or more characters. For example, ca* can match...
Navigating Linux File System and file management
Introduction Once you install a new operating system, the first thing to you want to do is navigate the file system. In this section we will look at how to navigate through the linux file system using the command prompt and also look at some useful commands to make our life easier. Understanding Linux file structure Before getting into the navigation, it is important to understand the file structure of linux operating system....
Command Substitution in Shell Script
Shell scripting offers a very helpful feature for the programmers called the Command substitution feature. Command substitution helps us store the output of a command in a variable. There are two ways of calling the command substitution: Using backtick (`) $ current_directory=`pwd` $ echo $current_directory /home/john $(command) format $ current_directory=$(pwd) $ echo $current_directory /home/john In the above commands, we are assigning the output of the pwd command to the variable current_directory....
Linux Shell Variables
Variables are containers used for storing data. They are named memory locations from where we can store and retrieve the values. Assigning variables in Shell script To assign a value to the variable we make use of = symbol as follows: name=Donald The above statement declares a variable name name and assigns it a string Donald. No spaces while assigning variables It is important to note the symbol = does not contain space before or after it....
Perl Subroutines
What is a subroutine in Perl? When you want to run a block of code which needs to be executed more than once, it makes sense to be able to group them such that it can be called any number of times to perform the same operation on different variables. In perl, you can do so by organizing them in functions or subroutines. This feature helps us by maintaining a clean, readable and well structured code that can be reused for related tasks....