SlideShare a Scribd company logo
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

Licão 13 functions
Licão 13 functionsLicão 13 functions
Licão 13 functions
Acácio Oliveira
 
Apend. networking generic b details
Apend. networking generic b detailsApend. networking generic b details
Apend. networking generic b details
Acá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 management
Acácio Oliveira
 
Licão 14 debug script
Licão 14 debug scriptLicão 14 debug script
Licão 14 debug script
Acá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 location
Acácio Oliveira
 
Licão 01 introduction
Licão 01 introductionLicão 01 introduction
Licão 01 introduction
Acácio Oliveira
 
Apend. networking generic a
Apend. networking generic aApend. networking generic a
Apend. networking generic a
Acá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 v2
Acácio Oliveira
 
Licão 11 decision making - statement
Licão 11 decision making - statementLicão 11 decision making - statement
Licão 11 decision making - statement
Acá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 iteration
Acácio Oliveira
 
Chapter09 -- networking with unix and linux
Chapter09  -- networking with unix and linuxChapter09  -- networking with unix and linux
Chapter09 -- networking with unix and linux
Raja 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 intro
Acá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 Techniques
Justin 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

SHELL PROGRAMMING.pptx
SHELL PROGRAMMING.pptxSHELL PROGRAMMING.pptx
SHELL PROGRAMMING.pptx
Technicaltamila2
 
php programming.pptx
php programming.pptxphp programming.pptx
php programming.pptx
rani marri
 
3- Operators in Java
3- Operators in Java3- Operators in Java
3- Operators in Java
Ghadeer AlHasan
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
Todd Barber
 
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$UltraUploader
 
SL-2.pptx
SL-2.pptxSL-2.pptx
Regexp secrets
Regexp secretsRegexp secrets
Regexp secrets
Hiro Asari
 
Linear algebra review
Linear algebra reviewLinear algebra review
Linear algebra reviewvevin1986
 
C operators
C operatorsC operators
C operators
Rupanshi rawat
 
Programming Fundamentals lecture 7
Programming Fundamentals lecture 7Programming Fundamentals lecture 7
Programming Fundamentals lecture 7
REHAN IJAZ
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
AllanGuevarra1
 
Py-Slides-2 (1).ppt
Py-Slides-2 (1).pptPy-Slides-2 (1).ppt
Py-Slides-2 (1).ppt
KalaiVani395886
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
TejaValmiki
 
python operators.ppt
python operators.pptpython operators.ppt
python operators.ppt
ErnieAcuna
 
C programming operators
C programming operatorsC programming operators
C programming operatorsSuneel Dogra
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
NBACriteria2SICET
 
C operators
C operators C operators
C operators
AbiramiT9
 
Programming with matlab session 4
Programming with matlab session 4Programming with matlab session 4
Programming with matlab session 4
Infinity Tech Solutions
 

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.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
 
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
 
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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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.pptx
Acá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

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

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