Wilcards&Arithmetics

#ysap #bashwildcards

The three main wildcard characters are:

Arithmetic Operators

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
variable++ Increase the value of the variable by 1
variable-- Decrease the value of the variable by 1
#!/bin/bash

increase=1 
decrease=1 
echo "Addition: 10 + 10 = $((10 + 10))" 
cho "Subtraction: 10 - 10 = $((10 - 10))" 
echo "Multiplication: 10 * 10 = $((10 * 10))" 
echo "Division: 10 / 10 = $((10 / 10))" 
echo "Modulus: 10 % 4 = $((10 % 4))" ((increase++)) 

echo "Increase Variable: $increase" ((decrease--)) 
echo "Decrease Variable: $decrease"

The output of this script looks like this:

#!/bin/bash

sosoBoy@htb[/htb]$ ./Arithmetic.sh 
Addition: 10 + 10 = 20 
Subtraction: 10 - 10 = 0 
Multiplication: 10 * 10 = 100
Division: 10 / 10 = 1 
Modulus: 10 % 4 = 2 
Increase Variable: 2 
Decrease Variable: 0

We can also calculate the length of the variable. Using this function ${#variable}, every character gets counted, and we get the total number of characters in the variable.

htb="HackTheBox"
echo ${#htb}

sosoBoy@htb[/htb]$ ./VarLength.sh
10

Example of script:
Attachments/Pasted image 20260612052719.png

Inner loop:

Powered by Forestry.md