Linuxopsys
Linuxopsys

@linuxopsys

56 Tweets 3 reads Oct 09, 2023
If you want to learn Linux bash scripting for FREE, open this:
1. What is Shell in Linux
In this guide, let's learn about the shell which is an important part of the Linux operating system which interprets and passes the commands you provide on your keyboard to the operating system to perform some specific tasks
linuxopsys.com
2. Bash variable assignment
A variable is a named storage location in a program's memory where a value can be stored, retrieved, and manipulated. Like any programming language, Variables are an essential component in the Bash scripts.
linuxopsys.com
2. Bash let with Examples
In bash, all variables are treated as strings. You cannot perform arithmetic operations on variables as you would normally do in other programming languages since bash interprets them as strings. To overcome this, bash has a built-in tool named let.
3. Bash expr with Examples
As we know bash variables are of string data type, performing arithmetic operations aren’t straightforward. However, bash provides us with several utilities to carry out arithmetic evaluations. One such command line tool is expr.
4. Bash Division Explained
We cannot divide numbers directly in Bash as they would be treated as strings. However, Bash provides a lot of tools and commands to perform arithmetic division.
In this guide, we are going to learn about different ways to divide with variables. We will also focus on the advantages and limitations of some of the commonly used methods. Furthermore, we will learn how to round the result of division
linuxopsys.com
5. Bash readarray with Examples
In every programming language, the term array means a collection of items that holds some data. The data would be in an indexed manner.
The unique property bash array is that it can save different types of elements. In this tutorial, we are going to learn about readarray.
linuxopsys.com
6. Loop through lines in a file using bash loops
The most efficient way to process any file, one line at a time, is to develop a bash script and give the file as input to the script. This can be done by reading a file line by line by iterating the lines over a loop.
Bash treats each line as an element in a list. Understanding how to process the contents of a large data file one line at a time saves us from constantly opening them. There are many ways of reading each line using Bash.
linuxopsys.com
7. Bash Modulo (Division Remainder)
Many times we are only interested in what the remainder is. The mod operator finds use in generating random numbers within a specific range and formatting program output.
It can even be used to generate prime numbers, check if a number is odd or even. Modulo turns up often in the majority of the numerical computations.
In this article, we will learn about the modulus operations in bash.
linuxopsys.com
8. Bash While Read Line by Line
When it comes to text processing or filtering logs, it becomes important to read the contents line by line. Using the bash while loop you can read the contents one line at a time and use it as per our needs.
9. Bash shift Command
Does your script accept a variable number of arguments? To easily process each argument, bash has shift command.
The command allows you to shift the positional parameters passed to a script.
In this tutorial, we learn about bash shift command with examples.
linuxopsys.com
10. 4 Ways to Check Which Shell You are Using on Linux
Out of the box, Linux provides a wide variety of shells. There is bash (Bourne Again shell) shell which ships by default in many Linux distributions.
We also have sh (Bourne Shell), tcsh (TC shell), csh (C shell), Zsh (Z shell) and ksh (Korn Shell).
Curious to know which shell you are using on your Linux system? In this guide, we explore different ways that you can use to check which shell you are currently using in Linux.
linuxopsys.com
11. Understanding Different Types of Shells in Linux
n the Linux realm, there are multiple shells available, each with its own unique features and capabilities to cater to the varying needs and also preferences of the user.
For instance, the Bourne shell (sh) offers a minimalist set of features for shell scripting, while the Z shell (zsh) offers some advanced ones such as extended globbing and spelling correction.
Therefore, choosing the shell can be subjective based on the task at hand and the specific requirements.
Although it's not necessary to learn all shells, acquiring knowledge on multiple ones can be necessary to improve efficiency....
(one shell for scripting and the other for interactive use) and to increase functionality (taking advantage of the best feature in each shell).
linuxopsys.com
12. Shell Script to Check Linux Server Health
In this tutorial, we will show how to write a shell script to perform a Linux server health check. This script collects system information and status like hostname, kernel version, uptime, CPU, memory, and disk usage.
13. Bash Command Line Chain Operators in Linux with Examples
Linux command chaining is a technique of combining several commands so that each of them can execute after the other based on the operator between them.
The operator that separates these commands is the most important aspect of command line chaining. These operators control how these commands get executed.
14. Bash Function Return Value
In Bash, functions do not support returning values like in other programming languages. Instead, the return value of a function is its exit status, a numeric value indicating success or failure. A zero exit status indicates success,
15. How to Pass all Arguments in Bash Scripting
Bash arguments are one of the ways users provide inputs to the executing scripts. Using bash arguments, we create reusable scripts avoiding redundant code.
16. Bash Parameter Expansion with Cheat Sheet
Any number or string value or list of values (numeric or associative array) can be stored using a variable in bash.
You can define variables in bash without using the `declare` command or by using the `declare` command where the data type is declared at the time of declaration. Bash parameter expansion or parameter expansion is defined by the β€˜$’ symbol and the optional curly brackets ({ }).
The parameter expansion is used with the curly brackets when it is required to read or modify the original parameter value. You have to use double quotes (β€œ) when expanding values by using parameter expansion.
17. How to Do Bash Variable Substitution (Parameter Substitution)
When the original value of any expression is substituted by another value then it is called substitution. Bash variable substitution or parameter substitution is a very useful feature of bash.
Generally, it is done in the bash by using the '$' character and the optional curly brackets ({}). The content of the bash variable can be checked or modified based on the programming requirements by using variable or parameter substitution.
18. How to Concatenate String Variables in Bash [Join Strings]
Two or more string variables of characters or numbers or a mix of characters and numbers can be concatenated easily in bash. The string variables are required to concatenate for different types of programming tasks.
19. source Command in Bash: A Practical Guide
Bash is a Unix shell and command language that provides users with an interface to the operating system. It is widely used on Linux and other Unix-like operating systems, as well as on Windows using the Windows Subsystem for Linux.
This tutorial will discuss about one of the most useful Bash command, source, which is used to execute commands from a file or script in the current shell environment.
linuxopsys.com
20. Customizing Your Bash Prompt in Linux: Changing Colors
One of the commonly used shell in Linux is bash. Even if there are many modern shells available, it's still the default shell in many Linux distributions.
In this tutorial, we learn how to change the color of specific parts of the bash prompt in Linux. Here we use ANSI escape codes within the PS1 variable.
linuxopsys.com
21. How to Make Bash Script Executable Using Chmod
In this tutorial, I am going through the steps to create a bash script and make the script executable using the chmod command.
22. How to Rename Multiple Directories in Linux at Once
To rename a single directory in Linux is simple and straightforward. Whereas to do with multiple directories, we need to use special commands, scripts, or a combination of different commands.
23. All the Ways to Rename Multiple Files in Linux
Linux users may have to rename file frequently and it is very easy to rename a single file. You can just use the mv command to rename one file.
There might also be situations where a user or a Linux system administrator may have to rename multiple files at once. This is a completely different case and Linux supports multiple tools and commands to rename multiple files in one go.
That's it for today's thread.
Thank you taking your time to read it.
If you enjoyed this thread, follow us @linuxopsys for future Linux posts, which we will be posting on a daily basis.

Loading suggestions...