[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJuly 12, 2023

How to use and ad variables on Bash Scrip.

How To Use And Ad Variables On Bash Scrip.

Bash scripting is a powerful tool for automating tasks in the Linux environment. One of the fundamental concepts in Bash scripting is variables. Variables allow you to store and manipulate data within a script. In this article, we will explore the basics of Bash script variables with simple examples.

  1. Variable Naming and Assignment:

  • Variables in Bash are case-sensitive and can consist of letters, numbers, and underscores.

  • To assign a value to a variable, use the “=” operator.

  • Example:

greeting
"Hello, World!"
age
25
  1. Accessing Variable Values:

  • To access the value of a variable, prefix it with the “

    #8221; symbol.

  • Example:

echo
$greeting
# Output: Hello, World!
echo
$age
# Output: 25
  1. Command Substitution:

  • Bash allows you to assign the output of a command to a variable using command substitution.

  • Example:

date
"Today's date is $current_date"
  1. Read-Only Variables:

  • You can make a variable read-only using the “readonly” command.

  • Example:

readonly
"John"
"Mike"
# This will produce an error
  1. Environment Variables:

  • Environment variables are predefined variables that are available to all Bash scripts.

  • Examples:

/home/u
/usr/
/sbin:/u
/local/
/usr/
/usr/
/sbin:/
  1. Arithmetic Operations:

  • Bash supports basic arithmetic operations using the “$(( ))” syntax.

  • aExmple:

num1
num2
sum
"The sum is: $sum"

Conclusion:

Understanding Bash script variables is crucial for writing effective scripts. By storing and manipulating data using variables, you can create dynamic and efficient scripts. Experiment with the examples provided to gain a better understanding of how variables work in Bash scripting. Happy scripting!

Keep reading
How to Configure Static IP Address on Ubuntu 18
February 21, 2023

How to Configure Static IP Address on Ubuntu 18

How to Configure Static IP Address on Ubuntu 18 The newer versions of Ubuntu uses ‘Predictable Network Interface Names’ that, by default, start with en[letter][number]. The first step is to identify the name of the ethernet interface you want to configure. To do so use the ip link command, as…

Read article
How to Test Network Throughput with iPerf on Debian and Ubuntu
February 21, 2023

How to Test Network Throughput with iPerf on Debian and Ubuntu

How to Test Network Throughput with iPerf on Debian and Ubuntu Install iPerf The iperf package is included in most Linux distribution’s repositories. Debian and Ubuntu apt-get install iperf How to Use iPerf iPerf must be installed on the computers at both ends of the connection you’re testing.

Read article
Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung
February 21, 2023

Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung

Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung When installing CentOS/RHEL 7 on a hardware box with huge amount of ram installed, the installation gets hung at: [ OK ] Started Anaconda NetworkManager configuration. Starting Anaconda NetworkManager configuration…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00