SlideShare a Scribd company logo
1 of 39
Lesson 10
• Shell Operators
• Arithmetic Evaluation
• Conditional Statements
Shell operators
Important Bourne Shell operators
• Arithmetic Operators
• Relational Operators
• Boolean Operators
• String Operators
• File Test Operators
Arithmetic Operators
Bourne shell didn't originally have any mechanism to perform simple arithmetic
It uses external programs - awk or program expr.
#!/bin/sh
val=`expr 2 + 2`
echo "Total value : $val"
result:
Total value : 4
• There must be spaces between operators and expressions 2+2 is not correct.
it should be written as 2 + 2.
• Complete expression should be enclosed between `` (inverted commas)
Arithmetic Operators
Ex. variable a holds 10 and variable b holds 20 then:
+ Addition - Adds values on either side of the operator
`expr $a + $b` will give 30
- Subtraction - Subtracts right hand operand from left hand operand
`expr $a - $b` will give -10
* Multiplication - Multiplies values on either side of the operator
`expr $a * $b` will give 200
/ Division - Divides left hand operand by right hand operand
`expr $b / $a` will give 2
% Modulus - Divides left hand operand by right hand operand and returns remainder
`expr $b % $a` will give 0
= Assignment - Assign right operand in left operand
a=$b would assign value of b into a
== Equality - Compares two numbers, if both are same then returns true.
[ $a == $b ] would return false
!= Not Equality - Compares two numbers, if both are different then returns true.
[ $a != $b ] would return true
All conditional expressions are put inside square braces with one spaces around them.
[ $a == $b ] is correct; [$a==$b] is incorrect.
All the arithmetical calculations are done using long integers.
Arithmetic expressions
#!/bin/sh
a=10
b=20
val=`expr $a + $b`
echo "a + b : $val"
val=`expr $a - $b`
echo "a - b : $val"
val=`expr $a * $b`
echo "a * b : $val"
val=`expr $b / $a`
echo "b / a : $val"
val=`expr $b % $a`
echo "b % a : $val"
if [ $a == $b ]
then
echo "a is equal to b"
fi
if [ $a != $b ]
then
echo "a is not equal to b"
fi
Exemple
Arithmetic expressions
a + b : 30
a - b : -10
a * b : 200
b / a : 2
b % a : 0
a is not equal to b
Exemple Result
• There must be spaces between operators and expressions 2+2 is not
correct, as it should be written as 2 + 2.
• Complete expression should be enclosed between `` (inverted commas)
• use  on the * symbol for multiplication.
• if...then...fi statement is a decision making statement (for later lessons:-)
Arithmetic expressions
$ let X=10+2*7
$ echo $X
24
$ let Y=X+2*4
$ echo $Y
32
The let statement can be used to do mathematical functions
$ echo “$((123+20))”
143
$ VALORE=$[123+20]
$ echo “$[123*$VALORE]”
17589
arithmetic expression can be evaluated with $[expression] or $((expression))
Arithmetic expressions
$ vi arithmetic.sh
#!/bin/bash
echo -n “Enter the first number: ”; read x
echo -n “Enter the second number: ”; read y
add=$(($x + $y))
sub=$(($x - $y))
mul=$(($x * $y))
div=$(($x / $y))
mod=$(($x % $y))
Echo ”sum: $add”…
Exemple
echo “Sum: $add”
echo “Difference: $sub”
echo “Product: $mul”
echo “Quotient: $div”
echo “Remainder: $mod”
Exemple Result
Conditional Statements
Conditionals let us decide whether to perform an action or not this decision
is taken by evaluating an expression.
basic form:
if [ expression ];
then
statements
elif [ expression ];
then
statements
else
statements
fi
the elif (else if) and else sections are optional
Put spaces after [ and before ], and around the operators and operands.
Expressions
An expression can be:
• String comparison
• Numeric comparison
• File operators
• Logical operators
An expression is represented by $[expression] or $((expression))
Relational Operators
Number Comparisons Expression
Bourne Shell supports relational operators which are specific to numeric values
These operators do not work for string values unless their value is numeric.
For example, following operators would work to check a relation between 10 and 20 as well as in
between "10" and "20" but not in between "ten" and "twenty".
eq Check if value of two operands are equal or not, if yes then condition becomes
true. [ $a -eq $b ] is not true.
-ne If value of two operands are equal or not, if values are not equal then condition
becomes true. [ $a -ne $b ] is true.
-gt If the value of left operand is greater than the value of right operand, if yes then
condition becomes true. [ $a -gt $b ] is not true.
-lt If the value of left operand is less than the value of right operand, if yes then
condition becomes true. [ $a -lt $b ] is true.
-ge If the value of left operand is greater than or equal to the value of right operand, if
yes then condition becomes true. [ $a -ge $b ] is not true.
-le If the value of left operand is less than or equal to the value of right operand, if yes
then condition becomes true. [ $a -le $b ] is true.
Ex. variable a holds 10 and variable b holds 20 then:
All conditional expressions would be put inside square braces with one spaces around them
[ $a <= $b ] is correct , [$a <= $b] is incorrect.
Relational Operators
Number Comparisons Expression
Simple Table
-eq compare if two numbers are equal
-ge compare if one number is greater than or equal to a number
-le compare if one number is less than or equal to a number
-ne compare if two numbers are not equal
-gt compare if one number is greater than another number
-lt compare if one number is less than another number
[ n1 -eq n2 ] (true if n1 same as n2, else false)
[ n1 -ge n2 ] (true if n1greater then or equal to n2, else false)
[ n1 -le n2 ] (true if n1 less then or equal to n2, else false)
[ n1 -ne n2 ] (true if n1 is not same as n2, else false)
[ n1 -gt n2 ] (true if n1 greater then n2, else false)
[ n1 -lt n2 ] (true if n1 less then n2, else false)
Relational Operators
Number Comparisons Expression
#!/bin/sh
a=10
b=20
if [ $a -eq $b ]
then
echo "$a -eq $b : a is equal to b"
else
echo "$a -eq $b: a is not equal to b"
fi
if [ $a -ne $b ]
then
echo "$a -ne $b: a is not equal to b"
else
echo "$a -ne $b : a is equal to b"
fi
if [ $a -gt $b ]
then
echo "$a -gt $b: a is greater than b"
else
echo "$a -gt $b: a is not greater than b"
fi
if [ $a -lt $b ]
then
echo "$a -lt $b: a is less than b"
else
echo "$a -lt $b: a is not less than b"
fi
if [ $a -ge $b ]
then
echo "$a -ge $b: a is greater or equal to b"
else
echo "$a -ge $b: a is not greater or equal
to b"
fi
if [ $a -le $b ]
then
echo "$a -le $b: a is less or equal to b"
else
echo "$a -le $b: a is not less or equal to b"
fi
Exemple
Relational Operators
Number Comparisons Expression
10 -eq 20: a is not equal to b
10 -ne 20: a is not equal to b
10 -gt 20: a is not greater than b
10 -lt 20: a is less than b
10 -ge 20: a is not greater or equal to b
10 -le 20: a is less or equal to b
Exemple Result
Relational Operators
Number Comparisons Expression
Exemple
$ vi number.sh
#!/bin/bash
echo -n “Enter a number 1 < x < 10: "
read num
if [ “$num” -lt 10 ]; then
if [ “$num” -gt 1 ]; then
echo “$num*$num=$(($num*$num))”
else
echo “Wrong insertion !”
fi
else
echo “Wrong insertion again !”
fi
String Operators
String Comparisons Expressions
= Checks if value of two operands are equal or not, if yes then condition becomes true.
[ $a = $b ] is not true.
!= Checks if the value of two operands are equal or not, if values are not equal then
condition becomes true.
[ $a != $b ] is true.
-z Checks if the given string operand size is zero. If it is zero length then it returns true.
[ -z $a ] is not true.
-n Checks if the given string operand size is non-zero. If it is non-zero length then it
returns true.
[ -z $a ] is not false.
Str Check if str is not the empty string. If it is empty then it returns false.
[ $a ] is not false.
Ex. variable a holds “abc” and variable b holds “efg” then:
String Operators
String Comparisons Expressions
Simple Table
= compare if two strings are equal
!= compare if two strings are not equal
-n evaluate if string length is greater than zero
-z evaluate if string length is equal to zero
[ s1 = s2 ] (true if s1 same as s2, else false)
[ s1 != s2 ] (true if s1 not same as s2, else false)
[ s1 ] (true if s1 is not empty, else false)
[ -n s1 ] (true if s1 has a length greater then 0, else false)
[ -z s2 ] (true if s2 has a length of 0, otherwise false)
String Operators
String Comparisons Expressions
#!/bin/sh
a="abc"
b="efg"
if [ $a = $b ]
then
echo "$a = $b : a is equal to b"
else
echo "$a = $b: a is not equal to b"
fi
if [ $a != $b ]
then
echo "$a != $b : a is not equal to b"
else
echo "$a != $b: a is equal to b"
fi
Exemple
if [ -z $a ]
then
echo "-z $a : string length is zero"
else
echo "-z $a : string length is not zero"
fi
if [ -n $a ]
then
echo "-n $a : string length is not zero"
else
echo "-n $a : string length is zero"
fi
if [ $a ]
then
echo "$a : string is not empty"
else
echo "$a : string is empty"
fi
String Operators
String Comparisons Expressions
abc = efg: a is not equal to b
abc != efg : a is not equal to b
-z abc : string length is not zero
-n abc : string length is not zero
abc : string is not empty
Exemple Result
String Operators
String Comparisons Expressions
$ vi user.sh
#!/bin/bash
echo -n “Enter your login name: "
read name
if [ “$name” = “$USER” ];
then
echo “Hello, $name. How are you today ?”
else
echo “You are not $USER, so who are you ?”
fi
Exemple
Boolean Operators
Logical operators Expressions
! This is logical negation.
This inverts a true condition into false and vice versa.
[ ! false ] is true.
-o This is logical OR.
If one of the operands is true then condition would be true.
[ $a -lt 20 -o $b -gt 100 ] is true.
-a This is logical AND.
If both the operands are true then condition would be true otherwise it would be false.
[ $a -lt 20 -a $b -gt 100 ] is false.
Ex. variable a holds 10 and variable b holds 20 then:
Boolean Operators
Logical operators Expressions
Simple Table
! negate (NOT) a logical expression
-a logically AND two logical expressions
-o logically OR two logical expressions
#!/bin/bash
echo -n “Enter a number 1 < x < 10:”
read num
if [ “$num” -gt 1 –a “$num” -lt 10 ];
then
echo “$num*$num=$(($num*$num))”
else
echo “Wrong insertion !”
fi
Exemple
Boolean Operators
Logical operators Expressions
a=10
b=20
if [ $a != $b ]
then
echo "$a != $b : a is not equal to b"
else
echo "$a != $b: a is equal to b"
fi
if [ $a -lt 100 -a $b -gt 15 ]
then
echo "$a -lt 100 -a $b -gt 15 : returns true"
else
echo "$a -lt 100 -a $b -gt 15 : returns false"
fi
if [ $a -lt 100 -o $b -gt 100 ]
then
echo "$a -lt 100 -o $b -gt 100 : returns true"
else
echo "$a -lt 100 -o $b -gt 100 : returns false"
fi
if [ $a -lt 5 -o $b -gt 100 ]
then
echo "$a -lt 100 -o $b -gt 100 : returns true"
else
echo "$a -lt 100 -o $b -gt 100 : returns false"
fi
Exemple
Boolean Operators
Logical operators Expressions
10 != 20 : a is not equal to b
10 -lt 100 -a 20 -gt 15 : returns true
10 -lt 100 -o 20 -gt 100 : returns true
10 -lt 5 -o 20 -gt 100 : returns false
Exemple Result
File Test Operators
Boolean Check condition
-b file Checks if file is a block special file if yes then condition becomes true. [ -b $file ] is false
-c file Checks if file is a character special file if yes then condition becomes true. [ -b $file ] is false
-d file Check if file is a directory if yes then condition becomes true. [ -d $file ] is not true
-f file Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true
[ -f $file ] is true
-g file Checks if file has its set group ID (SGID) bit set if yes then condition becomes true. [ -g $file ] is false
-k file Checks if file has its sticky bit set if yes then condition becomes true. [ -k $file ] is false
-p file Checks if file is a named pipe if yes then condition becomes true. [ -p $file ] is false
-t file Checks if file descriptor is open and associated with a terminal if yes then condition becomes true
[ -t $file ] is false
-u file Checks if file has its set user id (SUID) bit set if yes then condition becomes true. [ -u $file ] is false
-r file Checks if file is readable if yes then condition becomes true. [ -r $file ] is true
-w file Check if file is writable if yes then condition becomes true. [ -w $file ] is true
-x file Check if file is execute if yes then condition becomes true. [ -x $file ] is true
-s file Check if file has size greater than 0 if yes then condition becomes true. [ -s $file ] is true
-e file Check if file exists. Is true even if file is a directory but exists. [ -e $file ] is true
Ex. file holds an existing file name "test" whose size is 100 bytes and has read, write and execute permission on
File Test Operators
Boolean Check condition
Simple Table
-d check if path given is a directory
-f check if path given is a file
-e check if file name exists
-r check if read permission is set for file or directory
-s check if a file has a length greater than 0
-w check if write permission is set for a file or directory
-x check if execute permission is set for a file or directory
[ -d scripts ] (true if scripts is a directory, otherwise false)
[ -f scripts ] (true if scripts is a file, otherwise false)
[ -e scripts ] (true if scripts exists, otherwise false)
[ -s scripts ] (true if scripts length is greater then 0, else false)
[ -r scripts ] (true if scripts has the read permission, else false)
[ -w scripts ] (true if scripts has the write permission, else false)
[ -x scripts ] (true if scripts has the execute permission, else false)
File Test Operators
Boolean Check condition
#!/bin/bash
if [ -f /etc/fstab ];
then
cp /etc/fstab .
echo “Done.”
else
echo “This file does not exist.”
exit 1
fi
Exemple
File Test Operators
Boolean Check condition
Exercice
Write a shell script which:
• accepts a file name
• checks if file exists
• if file exists, copy the file to the same name + .bak + the current date
(if the backup file already exists ask if you want to replace it)
When done you should have the original file and one with a .bak at the end.
File Test Operators
Boolean Check condition
Exemple
Assume a variable file holds an existing file name "/root/scripts/user.sh" whose size is 100
bytes and has read, write and execute permission on:
#!/bin/sh
file="/root/scripts/user.sh"
if [ -r $file ]
then
echo "File has read access"
else
echo "File does not have read access"
fi
if [ -w $file ]
then
echo "File has write permission"
else
echo "File does not have write permission"
fi
if [ -x $file ]
then
echo "File has execute permission"
else
echo "File does not have execute permission"
fi
if [ -f $file ]
then
echo "File is an ordinary file"
else
echo "This is special file"
fi
if [ -d $file ]
then
echo "File is a directory"
else
echo "This is not a directory"
fi
if [ -s $file ]
then
echo "File size is zero"
else
echo "File size is not zero"
fi
if [ -e $file ]
then
echo "File exists"
else
echo "File does not exist"
fi
File Test Operators
Boolean Check condition
File has read access
File has write permission
File has execute permission
File is an ordinary file
This is not a directory
File size is zero
File exists
Exemple Result
C Shell Operators
Arithmetic and Logical Operators
( ) Change precedence
~ 1's complement
! Logical negation
* Multiply
/ Divide
% Modulo
+ Add
- Subtract
<< Left shift
>> Right shift
== String comparison for equality
!= String comparison for non equality
=~ Pattern matching
& Bitwise "and"
^ Bitwise "exclusive or"
| Bitwise "inclusive or"
&& Logical "and"
|| Logical "or"
++ Increment
-- Decrement
= Assignment
*= Multiply left side by right side and update left
side
/= Divide left side by right side and update left
side
+= Add left side to right side and update left side
-= Subtract left side from right side and update left side
^= "Exclusive or" left side to right side and update
left side
%= Divide left by right side and update left side
with remainder
C Shell Operators
File Test Operators
-r file Checks if file is readable if yes then condition becomes true.
-w file Check if file is writable if yes then condition becomes true.
-x file Check if file is execute if yes then condition becomes true.
-f file Check if file is an ordinary file as opposed to a directory or special file if yes
then condition becomes true.
-z file Check if file has size greater than 0 if yes then condition becomes true.
-d file Check if file is a directory if yes then condition becomes true.
-e file Check if file exists. Is true even if file is a directory but exists.
-o file Check if user owns the file. It returns true if user is the owner of the file.
Korn Shell Operators
Arithmetic and Logical Operators
+ Unary plus
- Unary minus
!~ Logical negation; binary inversion (one's complement)
* Multiply
/ Divide
% Modulo
+ Add
- Subtract
<< Left shift
>> Right shift
== String comparison for equality
!= String comparison for non equality
=~ Pattern matching
& Bitwise "and"
^ Bitwise "exclusive or"
| Bitwise "inclusive or"
&& Logical "and"
|| Logical "or"
++ Increment
-- Decrement
= Assignment
Korn Shell Operators
File Test Operators
-r file Checks if file is readable if yes then condition becomes true.
-w file Check if file is writable if yes then condition becomes true.
-x file Check if file is execute if yes then condition becomes true.
-f file Check if file is an ordinary file as opposed to a directory or special file if yes
then condition becomes true.
-s file Check if file has size greater than 0 if yes then condition becomes true.
-d file Check if file is a directory if yes then condition becomes true.
-e file Check if file exists. Is true even if file is a directory but exists.
Korn/C Shell Logical Operators
Exemple
#!/bin/bash
echo -n "Enter a number 1 < x < 10: "
read num
if [ “$number” -gt 1 ] && [ “$number” -lt 10 ];
then
echo “$num*$num=$(($num*$num))”
else
echo “Wrong insertion !”
fi
Exemple
$ vi iftrue.sh
#!/bin/bash
echo “Enter a path: ”; read x
if cd $x; then
echo “I am in $x and it contains”; ls
else
echo “The directory $x does not exist”;
exit 1
fi
$ iftrue.sh
Enter a path: /home
userid otherid …
$ iftrue.sh
Enter a path: blah
The directory blah does not exist
Shell Parameters
Positional parameters
Variable Description
$0 The filename of the current script.
$n These variables correspond to the arguments with which a script was invoked.
Here n is a positive decimal number corresponding to the position of an argument
(the first argument is $1, the second argument is $2, and so on).
$# The number of arguments supplied to a script.
$* All the arguments are double quoted. If a script receives two arguments, $* is
equivalent to $1 $2.
$@ All the arguments are individually double quoted. If a script receives two
arguments, $@ is equivalent to $1 $2.
$? The exit status of the last command executed.
$$ The process number of the current shell. For shell scripts, this is the process ID
under which they are executing.
$! The process number of the last background command.
Positional parameters are assigned from the shell’s argument when it is invoked.
Positional parameter “N” may be referenced as “${N}”,
or as “$N” when “N” consists of a single digit.
$# is the number of parameters passed
$0 returns the name of the shell script running as well as its location in the file system
$* gives a single word containing all the parameters passed to the script
$@ gives an array of words containing all the parameters passed to the script
$ cat sparameters.sh
#!/bin/bash
echo “$#; $0; $1; $2; $*; $@”
$ sparameters.sh arg1 arg2
2; ./sparameters.sh; arg1; arg2; arg1 arg2; arg1 arg2
Shell Parameters
Positional parameters
Shell Parameters
Positional parameters
$ vi trash.sh
#!/bin/bash
if [ $# -eq 1 ];
then
if [ ! –d “$HOME/trash” ];
then
mkdir “$HOME/trash”
fi
mv $1 “$HOME/trash”
else
echo “Use: $0 filename”
exit 1
fi

More Related Content

Viewers also liked

Apend. networking generic b details
Apend. networking generic b detailsApend. networking generic b details
Apend. networking generic b detailsAcácio Oliveira
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package managementAcácio Oliveira
 
4.7 find system files and place files in the correct location
4.7 find system files and place files in the correct location4.7 find system files and place files in the correct location
4.7 find system files and place files in the correct locationAcácio Oliveira
 
Apend. networking generic a
Apend. networking generic aApend. networking generic a
Apend. networking generic aAcácio Oliveira
 
2.4.1 use debian package management v2
2.4.1 use debian package management v22.4.1 use debian package management v2
2.4.1 use debian package management v2Acácio Oliveira
 
Licão 11 decision making - statement
Licão 11 decision making - statementLicão 11 decision making - statement
Licão 11 decision making - statementAcácio Oliveira
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationAcácio Oliveira
 
Chapter09 -- networking with unix and linux
Chapter09  -- networking with unix and linuxChapter09  -- networking with unix and linux
Chapter09 -- networking with unix and linuxRaja Waseem Akhtar
 
Licão 02 shell basics bash intro
Licão 02 shell basics bash introLicão 02 shell basics bash intro
Licão 02 shell basics bash introAcácio Oliveira
 
101 4.7 find system files and place files in the correct location
101 4.7 find system files and place files in the correct location101 4.7 find system files and place files in the correct location
101 4.7 find system files and place files in the correct locationAcácio Oliveira
 
101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystemsAcácio Oliveira
 
Processing Techniques
Processing TechniquesProcessing Techniques
Processing TechniquesJustin Caris
 
101 4.4 manage disk quotas
101 4.4 manage disk quotas101 4.4 manage disk quotas
101 4.4 manage disk quotasAcácio Oliveira
 
Lpi lição 01 exam 102 objectives
Lpi lição 01  exam 102 objectivesLpi lição 01  exam 102 objectives
Lpi lição 01 exam 102 objectivesAcácio Oliveira
 

Viewers also liked (20)

Licão 13 functions
Licão 13 functionsLicão 13 functions
Licão 13 functions
 
Apend. networking generic b details
Apend. networking generic b detailsApend. networking generic b details
Apend. networking generic b details
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
 
Licão 14 debug script
Licão 14 debug scriptLicão 14 debug script
Licão 14 debug script
 
4.7 find system files and place files in the correct location
4.7 find system files and place files in the correct location4.7 find system files and place files in the correct location
4.7 find system files and place files in the correct location
 
Licão 01 introduction
Licão 01 introductionLicão 01 introduction
Licão 01 introduction
 
Apend. networking generic a
Apend. networking generic aApend. networking generic a
Apend. networking generic a
 
2.4.1 use debian package management v2
2.4.1 use debian package management v22.4.1 use debian package management v2
2.4.1 use debian package management v2
 
Licão 11 decision making - statement
Licão 11 decision making - statementLicão 11 decision making - statement
Licão 11 decision making - statement
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iteration
 
Jscript part1
Jscript part1Jscript part1
Jscript part1
 
Chapter09 -- networking with unix and linux
Chapter09  -- networking with unix and linuxChapter09  -- networking with unix and linux
Chapter09 -- networking with unix and linux
 
Licão 02 shell basics bash intro
Licão 02 shell basics bash introLicão 02 shell basics bash intro
Licão 02 shell basics bash intro
 
101 4.7 find system files and place files in the correct location
101 4.7 find system files and place files in the correct location101 4.7 find system files and place files in the correct location
101 4.7 find system files and place files in the correct location
 
101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems
 
Processing Techniques
Processing TechniquesProcessing Techniques
Processing Techniques
 
101 1.1 hardware settings
101 1.1 hardware settings101 1.1 hardware settings
101 1.1 hardware settings
 
101 4.4 manage disk quotas
101 4.4 manage disk quotas101 4.4 manage disk quotas
101 4.4 manage disk quotas
 
Lpi lição 01 exam 102 objectives
Lpi lição 01  exam 102 objectivesLpi lição 01  exam 102 objectives
Lpi lição 01 exam 102 objectives
 
101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
 

Similar to Licão 10 operators

Similar to Licão 10 operators (20)

SHELL PROGRAMMING.pptx
SHELL PROGRAMMING.pptxSHELL PROGRAMMING.pptx
SHELL PROGRAMMING.pptx
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
 
3- Operators in Java
3- Operators in Java3- Operators in Java
3- Operators in Java
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
 
SL-2.pptx
SL-2.pptxSL-2.pptx
SL-2.pptx
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Regexp secrets
Regexp secretsRegexp secrets
Regexp secrets
 
Linear algebra review
Linear algebra reviewLinear algebra review
Linear algebra review
 
C operators
C operatorsC operators
C operators
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
 
Py-Slides-2 (1).ppt
Py-Slides-2 (1).pptPy-Slides-2 (1).ppt
Py-Slides-2 (1).ppt
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
 
python operators.ppt
python operators.pptpython operators.ppt
python operators.ppt
 
C programming operators
C programming operatorsC programming operators
C programming operators
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
C operators
C operators C operators
C operators
 
Programming with matlab session 4
Programming with matlab session 4Programming with matlab session 4
Programming with matlab session 4
 

More from Acácio Oliveira

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Acácio Oliveira
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Acácio Oliveira
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxAcácio Oliveira
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxAcácio Oliveira
 

More from Acácio Oliveira (20)

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
 

Recently uploaded

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Licão 10 operators

  • 1. Lesson 10 • Shell Operators • Arithmetic Evaluation • Conditional Statements
  • 2. Shell operators Important Bourne Shell operators • Arithmetic Operators • Relational Operators • Boolean Operators • String Operators • File Test Operators
  • 3. Arithmetic Operators Bourne shell didn't originally have any mechanism to perform simple arithmetic It uses external programs - awk or program expr. #!/bin/sh val=`expr 2 + 2` echo "Total value : $val" result: Total value : 4 • There must be spaces between operators and expressions 2+2 is not correct. it should be written as 2 + 2. • Complete expression should be enclosed between `` (inverted commas)
  • 4. Arithmetic Operators Ex. variable a holds 10 and variable b holds 20 then: + Addition - Adds values on either side of the operator `expr $a + $b` will give 30 - Subtraction - Subtracts right hand operand from left hand operand `expr $a - $b` will give -10 * Multiplication - Multiplies values on either side of the operator `expr $a * $b` will give 200 / Division - Divides left hand operand by right hand operand `expr $b / $a` will give 2 % Modulus - Divides left hand operand by right hand operand and returns remainder `expr $b % $a` will give 0 = Assignment - Assign right operand in left operand a=$b would assign value of b into a == Equality - Compares two numbers, if both are same then returns true. [ $a == $b ] would return false != Not Equality - Compares two numbers, if both are different then returns true. [ $a != $b ] would return true All conditional expressions are put inside square braces with one spaces around them. [ $a == $b ] is correct; [$a==$b] is incorrect. All the arithmetical calculations are done using long integers.
  • 5. Arithmetic expressions #!/bin/sh a=10 b=20 val=`expr $a + $b` echo "a + b : $val" val=`expr $a - $b` echo "a - b : $val" val=`expr $a * $b` echo "a * b : $val" val=`expr $b / $a` echo "b / a : $val" val=`expr $b % $a` echo "b % a : $val" if [ $a == $b ] then echo "a is equal to b" fi if [ $a != $b ] then echo "a is not equal to b" fi Exemple
  • 6. Arithmetic expressions a + b : 30 a - b : -10 a * b : 200 b / a : 2 b % a : 0 a is not equal to b Exemple Result • There must be spaces between operators and expressions 2+2 is not correct, as it should be written as 2 + 2. • Complete expression should be enclosed between `` (inverted commas) • use on the * symbol for multiplication. • if...then...fi statement is a decision making statement (for later lessons:-)
  • 7. Arithmetic expressions $ let X=10+2*7 $ echo $X 24 $ let Y=X+2*4 $ echo $Y 32 The let statement can be used to do mathematical functions $ echo “$((123+20))” 143 $ VALORE=$[123+20] $ echo “$[123*$VALORE]” 17589 arithmetic expression can be evaluated with $[expression] or $((expression))
  • 8. Arithmetic expressions $ vi arithmetic.sh #!/bin/bash echo -n “Enter the first number: ”; read x echo -n “Enter the second number: ”; read y add=$(($x + $y)) sub=$(($x - $y)) mul=$(($x * $y)) div=$(($x / $y)) mod=$(($x % $y)) Echo ”sum: $add”… Exemple echo “Sum: $add” echo “Difference: $sub” echo “Product: $mul” echo “Quotient: $div” echo “Remainder: $mod” Exemple Result
  • 9. Conditional Statements Conditionals let us decide whether to perform an action or not this decision is taken by evaluating an expression. basic form: if [ expression ]; then statements elif [ expression ]; then statements else statements fi the elif (else if) and else sections are optional Put spaces after [ and before ], and around the operators and operands.
  • 10. Expressions An expression can be: • String comparison • Numeric comparison • File operators • Logical operators An expression is represented by $[expression] or $((expression))
  • 11. Relational Operators Number Comparisons Expression Bourne Shell supports relational operators which are specific to numeric values These operators do not work for string values unless their value is numeric. For example, following operators would work to check a relation between 10 and 20 as well as in between "10" and "20" but not in between "ten" and "twenty". eq Check if value of two operands are equal or not, if yes then condition becomes true. [ $a -eq $b ] is not true. -ne If value of two operands are equal or not, if values are not equal then condition becomes true. [ $a -ne $b ] is true. -gt If the value of left operand is greater than the value of right operand, if yes then condition becomes true. [ $a -gt $b ] is not true. -lt If the value of left operand is less than the value of right operand, if yes then condition becomes true. [ $a -lt $b ] is true. -ge If the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. [ $a -ge $b ] is not true. -le If the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. [ $a -le $b ] is true. Ex. variable a holds 10 and variable b holds 20 then: All conditional expressions would be put inside square braces with one spaces around them [ $a <= $b ] is correct , [$a <= $b] is incorrect.
  • 12. Relational Operators Number Comparisons Expression Simple Table -eq compare if two numbers are equal -ge compare if one number is greater than or equal to a number -le compare if one number is less than or equal to a number -ne compare if two numbers are not equal -gt compare if one number is greater than another number -lt compare if one number is less than another number [ n1 -eq n2 ] (true if n1 same as n2, else false) [ n1 -ge n2 ] (true if n1greater then or equal to n2, else false) [ n1 -le n2 ] (true if n1 less then or equal to n2, else false) [ n1 -ne n2 ] (true if n1 is not same as n2, else false) [ n1 -gt n2 ] (true if n1 greater then n2, else false) [ n1 -lt n2 ] (true if n1 less then n2, else false)
  • 13. Relational Operators Number Comparisons Expression #!/bin/sh a=10 b=20 if [ $a -eq $b ] then echo "$a -eq $b : a is equal to b" else echo "$a -eq $b: a is not equal to b" fi if [ $a -ne $b ] then echo "$a -ne $b: a is not equal to b" else echo "$a -ne $b : a is equal to b" fi if [ $a -gt $b ] then echo "$a -gt $b: a is greater than b" else echo "$a -gt $b: a is not greater than b" fi if [ $a -lt $b ] then echo "$a -lt $b: a is less than b" else echo "$a -lt $b: a is not less than b" fi if [ $a -ge $b ] then echo "$a -ge $b: a is greater or equal to b" else echo "$a -ge $b: a is not greater or equal to b" fi if [ $a -le $b ] then echo "$a -le $b: a is less or equal to b" else echo "$a -le $b: a is not less or equal to b" fi Exemple
  • 14. Relational Operators Number Comparisons Expression 10 -eq 20: a is not equal to b 10 -ne 20: a is not equal to b 10 -gt 20: a is not greater than b 10 -lt 20: a is less than b 10 -ge 20: a is not greater or equal to b 10 -le 20: a is less or equal to b Exemple Result
  • 15. Relational Operators Number Comparisons Expression Exemple $ vi number.sh #!/bin/bash echo -n “Enter a number 1 < x < 10: " read num if [ “$num” -lt 10 ]; then if [ “$num” -gt 1 ]; then echo “$num*$num=$(($num*$num))” else echo “Wrong insertion !” fi else echo “Wrong insertion again !” fi
  • 16. String Operators String Comparisons Expressions = Checks if value of two operands are equal or not, if yes then condition becomes true. [ $a = $b ] is not true. != Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. [ $a != $b ] is true. -z Checks if the given string operand size is zero. If it is zero length then it returns true. [ -z $a ] is not true. -n Checks if the given string operand size is non-zero. If it is non-zero length then it returns true. [ -z $a ] is not false. Str Check if str is not the empty string. If it is empty then it returns false. [ $a ] is not false. Ex. variable a holds “abc” and variable b holds “efg” then:
  • 17. String Operators String Comparisons Expressions Simple Table = compare if two strings are equal != compare if two strings are not equal -n evaluate if string length is greater than zero -z evaluate if string length is equal to zero [ s1 = s2 ] (true if s1 same as s2, else false) [ s1 != s2 ] (true if s1 not same as s2, else false) [ s1 ] (true if s1 is not empty, else false) [ -n s1 ] (true if s1 has a length greater then 0, else false) [ -z s2 ] (true if s2 has a length of 0, otherwise false)
  • 18. String Operators String Comparisons Expressions #!/bin/sh a="abc" b="efg" if [ $a = $b ] then echo "$a = $b : a is equal to b" else echo "$a = $b: a is not equal to b" fi if [ $a != $b ] then echo "$a != $b : a is not equal to b" else echo "$a != $b: a is equal to b" fi Exemple if [ -z $a ] then echo "-z $a : string length is zero" else echo "-z $a : string length is not zero" fi if [ -n $a ] then echo "-n $a : string length is not zero" else echo "-n $a : string length is zero" fi if [ $a ] then echo "$a : string is not empty" else echo "$a : string is empty" fi
  • 19. String Operators String Comparisons Expressions abc = efg: a is not equal to b abc != efg : a is not equal to b -z abc : string length is not zero -n abc : string length is not zero abc : string is not empty Exemple Result
  • 20. String Operators String Comparisons Expressions $ vi user.sh #!/bin/bash echo -n “Enter your login name: " read name if [ “$name” = “$USER” ]; then echo “Hello, $name. How are you today ?” else echo “You are not $USER, so who are you ?” fi Exemple
  • 21. Boolean Operators Logical operators Expressions ! This is logical negation. This inverts a true condition into false and vice versa. [ ! false ] is true. -o This is logical OR. If one of the operands is true then condition would be true. [ $a -lt 20 -o $b -gt 100 ] is true. -a This is logical AND. If both the operands are true then condition would be true otherwise it would be false. [ $a -lt 20 -a $b -gt 100 ] is false. Ex. variable a holds 10 and variable b holds 20 then:
  • 22. Boolean Operators Logical operators Expressions Simple Table ! negate (NOT) a logical expression -a logically AND two logical expressions -o logically OR two logical expressions #!/bin/bash echo -n “Enter a number 1 < x < 10:” read num if [ “$num” -gt 1 –a “$num” -lt 10 ]; then echo “$num*$num=$(($num*$num))” else echo “Wrong insertion !” fi Exemple
  • 23. Boolean Operators Logical operators Expressions a=10 b=20 if [ $a != $b ] then echo "$a != $b : a is not equal to b" else echo "$a != $b: a is equal to b" fi if [ $a -lt 100 -a $b -gt 15 ] then echo "$a -lt 100 -a $b -gt 15 : returns true" else echo "$a -lt 100 -a $b -gt 15 : returns false" fi if [ $a -lt 100 -o $b -gt 100 ] then echo "$a -lt 100 -o $b -gt 100 : returns true" else echo "$a -lt 100 -o $b -gt 100 : returns false" fi if [ $a -lt 5 -o $b -gt 100 ] then echo "$a -lt 100 -o $b -gt 100 : returns true" else echo "$a -lt 100 -o $b -gt 100 : returns false" fi Exemple
  • 24. Boolean Operators Logical operators Expressions 10 != 20 : a is not equal to b 10 -lt 100 -a 20 -gt 15 : returns true 10 -lt 100 -o 20 -gt 100 : returns true 10 -lt 5 -o 20 -gt 100 : returns false Exemple Result
  • 25. File Test Operators Boolean Check condition -b file Checks if file is a block special file if yes then condition becomes true. [ -b $file ] is false -c file Checks if file is a character special file if yes then condition becomes true. [ -b $file ] is false -d file Check if file is a directory if yes then condition becomes true. [ -d $file ] is not true -f file Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true [ -f $file ] is true -g file Checks if file has its set group ID (SGID) bit set if yes then condition becomes true. [ -g $file ] is false -k file Checks if file has its sticky bit set if yes then condition becomes true. [ -k $file ] is false -p file Checks if file is a named pipe if yes then condition becomes true. [ -p $file ] is false -t file Checks if file descriptor is open and associated with a terminal if yes then condition becomes true [ -t $file ] is false -u file Checks if file has its set user id (SUID) bit set if yes then condition becomes true. [ -u $file ] is false -r file Checks if file is readable if yes then condition becomes true. [ -r $file ] is true -w file Check if file is writable if yes then condition becomes true. [ -w $file ] is true -x file Check if file is execute if yes then condition becomes true. [ -x $file ] is true -s file Check if file has size greater than 0 if yes then condition becomes true. [ -s $file ] is true -e file Check if file exists. Is true even if file is a directory but exists. [ -e $file ] is true Ex. file holds an existing file name "test" whose size is 100 bytes and has read, write and execute permission on
  • 26. File Test Operators Boolean Check condition Simple Table -d check if path given is a directory -f check if path given is a file -e check if file name exists -r check if read permission is set for file or directory -s check if a file has a length greater than 0 -w check if write permission is set for a file or directory -x check if execute permission is set for a file or directory [ -d scripts ] (true if scripts is a directory, otherwise false) [ -f scripts ] (true if scripts is a file, otherwise false) [ -e scripts ] (true if scripts exists, otherwise false) [ -s scripts ] (true if scripts length is greater then 0, else false) [ -r scripts ] (true if scripts has the read permission, else false) [ -w scripts ] (true if scripts has the write permission, else false) [ -x scripts ] (true if scripts has the execute permission, else false)
  • 27. File Test Operators Boolean Check condition #!/bin/bash if [ -f /etc/fstab ]; then cp /etc/fstab . echo “Done.” else echo “This file does not exist.” exit 1 fi Exemple
  • 28. File Test Operators Boolean Check condition Exercice Write a shell script which: • accepts a file name • checks if file exists • if file exists, copy the file to the same name + .bak + the current date (if the backup file already exists ask if you want to replace it) When done you should have the original file and one with a .bak at the end.
  • 29. File Test Operators Boolean Check condition Exemple Assume a variable file holds an existing file name "/root/scripts/user.sh" whose size is 100 bytes and has read, write and execute permission on: #!/bin/sh file="/root/scripts/user.sh" if [ -r $file ] then echo "File has read access" else echo "File does not have read access" fi if [ -w $file ] then echo "File has write permission" else echo "File does not have write permission" fi if [ -x $file ] then echo "File has execute permission" else echo "File does not have execute permission" fi if [ -f $file ] then echo "File is an ordinary file" else echo "This is special file" fi if [ -d $file ] then echo "File is a directory" else echo "This is not a directory" fi if [ -s $file ] then echo "File size is zero" else echo "File size is not zero" fi if [ -e $file ] then echo "File exists" else echo "File does not exist" fi
  • 30. File Test Operators Boolean Check condition File has read access File has write permission File has execute permission File is an ordinary file This is not a directory File size is zero File exists Exemple Result
  • 31. C Shell Operators Arithmetic and Logical Operators ( ) Change precedence ~ 1's complement ! Logical negation * Multiply / Divide % Modulo + Add - Subtract << Left shift >> Right shift == String comparison for equality != String comparison for non equality =~ Pattern matching & Bitwise "and" ^ Bitwise "exclusive or" | Bitwise "inclusive or" && Logical "and" || Logical "or" ++ Increment -- Decrement = Assignment *= Multiply left side by right side and update left side /= Divide left side by right side and update left side += Add left side to right side and update left side -= Subtract left side from right side and update left side ^= "Exclusive or" left side to right side and update left side %= Divide left by right side and update left side with remainder
  • 32. C Shell Operators File Test Operators -r file Checks if file is readable if yes then condition becomes true. -w file Check if file is writable if yes then condition becomes true. -x file Check if file is execute if yes then condition becomes true. -f file Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true. -z file Check if file has size greater than 0 if yes then condition becomes true. -d file Check if file is a directory if yes then condition becomes true. -e file Check if file exists. Is true even if file is a directory but exists. -o file Check if user owns the file. It returns true if user is the owner of the file.
  • 33. Korn Shell Operators Arithmetic and Logical Operators + Unary plus - Unary minus !~ Logical negation; binary inversion (one's complement) * Multiply / Divide % Modulo + Add - Subtract << Left shift >> Right shift == String comparison for equality != String comparison for non equality =~ Pattern matching & Bitwise "and" ^ Bitwise "exclusive or" | Bitwise "inclusive or" && Logical "and" || Logical "or" ++ Increment -- Decrement = Assignment
  • 34. Korn Shell Operators File Test Operators -r file Checks if file is readable if yes then condition becomes true. -w file Check if file is writable if yes then condition becomes true. -x file Check if file is execute if yes then condition becomes true. -f file Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true. -s file Check if file has size greater than 0 if yes then condition becomes true. -d file Check if file is a directory if yes then condition becomes true. -e file Check if file exists. Is true even if file is a directory but exists.
  • 35. Korn/C Shell Logical Operators Exemple #!/bin/bash echo -n "Enter a number 1 < x < 10: " read num if [ “$number” -gt 1 ] && [ “$number” -lt 10 ]; then echo “$num*$num=$(($num*$num))” else echo “Wrong insertion !” fi
  • 36. Exemple $ vi iftrue.sh #!/bin/bash echo “Enter a path: ”; read x if cd $x; then echo “I am in $x and it contains”; ls else echo “The directory $x does not exist”; exit 1 fi $ iftrue.sh Enter a path: /home userid otherid … $ iftrue.sh Enter a path: blah The directory blah does not exist
  • 37. Shell Parameters Positional parameters Variable Description $0 The filename of the current script. $n These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on). $# The number of arguments supplied to a script. $* All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2. $@ All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2. $? The exit status of the last command executed. $$ The process number of the current shell. For shell scripts, this is the process ID under which they are executing. $! The process number of the last background command.
  • 38. Positional parameters are assigned from the shell’s argument when it is invoked. Positional parameter “N” may be referenced as “${N}”, or as “$N” when “N” consists of a single digit. $# is the number of parameters passed $0 returns the name of the shell script running as well as its location in the file system $* gives a single word containing all the parameters passed to the script $@ gives an array of words containing all the parameters passed to the script $ cat sparameters.sh #!/bin/bash echo “$#; $0; $1; $2; $*; $@” $ sparameters.sh arg1 arg2 2; ./sparameters.sh; arg1; arg2; arg1 arg2; arg1 arg2 Shell Parameters Positional parameters
  • 39. Shell Parameters Positional parameters $ vi trash.sh #!/bin/bash if [ $# -eq 1 ]; then if [ ! –d “$HOME/trash” ]; then mkdir “$HOME/trash” fi mv $1 “$HOME/trash” else echo “Use: $0 filename” exit 1 fi