Mindblown: a blog about philosophy.
-
Shell Scripting let command
The let command is an arithmetic operator. It is almost same as (( )). Only difference is that, let is an arithmetic command while (( )) is a compound command. It is a built-in command which instructs shell to perform an evaluation of arithmetic expressions. No spaces should be used around the arithmetic operant with let command. Look at…
-
Shell Scripting eval command
The eval command is a built-in command. It takes a string as its argument and evaluate it, then run the command stored in the argument. It allows using the value of a variable as a variable. Example 1: Look at the above snapshot, command “echo \${$User}” runs $User as a shell variable and displays its output. But…
-
Shell Scripting case
A case construct helps us to simplify nested if statement. You can match several variables against one variable. Each case is an expression matching a certain pattern. Syntax: Look at the above snapshot, you can write one pattern or more than one pattern together according to the situation. Let’s see an example to understand it…
-
Shell Functions
With the help of functions, overall functionality of a function can be divided into smaller or logical parts, which can be called to perform their task. It helps us to check our program part by part. We can reuse the function where ever we want. To create a function Syntax: You will call your function…
-
Shell Scripting until loop
It is similar to while loop. The only difference is that until statement executes its code block while its conditional expression is false, and while statement executes its code block while its conditional expression is true. Difference between while and until Until loop always executes at least once. Loop while executes till it returns a zero value and until…
-
Shell Scripting while loop
Linux scripting while loop is similar to C language while loop. There is a condition in while. And commands are executed till the condition is valid. Once condition becomes false, loop terminates. Syntax: Syntax of while loop is shown in the snapshot below, Example: We have shown the example of printing number in reverse order.…
-
Shell Scripting for loop
The for loop moves through a specified list of values until the list is exhausted. 1) Syntax: Syntax of for loop using in and list of values is shown below. This for loop contains a number of variables in the list and will execute for each item in the list. For example, if there are 10 variables…
-
Shell Scripting if then elif
A new if can be nested inside an elif. Syntax: Syntax of if then elif is shown in the snapshot below, Example if then elif: We have shown the example of choosing color. Condition: Look at the above snapshot, we have shown the script. Look at the above snapshot, on Red color it goes to if part, on Blue color it goes…
-
Shell Scripting if then else
The if then else condition loop states that if condition meets, output goes to if part otherwise it goes to else part. The word fi represents if loop termination . Syntax: Syntax of if then else is shown in the snapshot below, Example if then else: We have shown the example of voting. If user’s age will be greater than 18…
-
Example 2 with argument:
Look at the above snapshot, argument is required with option b. Look at the above snapshot, this is the sample output of above script.
Got any book recommendations?