Linux - String operators
Nov 28, 2024
Linux - String operators
View Video Transcript
0:00
so let us check our string operators now
0:02
as we have already discussed which we
0:04
can use as strings for licking out or
0:07
checking out our operators and variables
0:10
same here we can use different kind of
0:12
operators using the string called as
0:14
equals to so equals to will be used for
0:17
click again checking on two of different
0:20
operators we have area below one and
0:22
variable B but we do not have any
0:24
expressions added into it
0:26
so directly we can add your a and B and
0:28
we can check whether this particular
0:30
variables which we have added are equal
0:33
or not same way we can use not equals to
0:36
sign which we can also use into your
0:38
operators other operators as well where
0:41
we can compare both the values and we
0:44
can define they're not equal to or not
0:47
next we have - said - said we'll check
0:51
whether the value of this variable is 0
0:54
or not if it is 0 the value will get
0:57
true and if it is false if it is not 0
1:01
the value will get false the next we
1:03
have - and - and is for checking whether
1:06
the value of a is 0 or nonzero so
1:10
generally -
1:11
enmons nonzero so - n of a is nonzero
1:15
that means the variable a is not 0 it
1:20
can be above number of tries ero it can
1:22
be 1 it can be 2 but not the 0 then we
1:25
have STR STR means empty string we do
1:28
not have anything into the variable a
1:30
just variable we have created and we can
1:32
letter add the strings by using the
1:35
input commands or we can add it later
1:37
wires so this are the different type of
1:39
string operators which generally we have
1:41
so let us check on our terminal how we
1:44
can use this operators into our program
1:46
so here in condition I have checked for
1:49
my same file with a particular value I'm
1:54
going to add and I want to enter a file
1:57
name so it will read a file name it will
2:00
check whether the file it is a file or
2:03
it is directory that is a file it will
2:05
show me this is a file if it is
2:07
directory it will show me the set
2:08
directory so this is a just I'm going to
2:12
check the file if I use -
2:13
we'll check for the directory if I use -
2:15
I have faith we'll check for the files
2:18
so right now I want to check for the
2:20
files if it is a file it will show me in
2:22
the file if the name is in the directory
2:25
it will show me it is a directory so let
2:28
us check how it works now here I'm going
2:30
to add a file now touch sample file 1
2:37
this is the file and same way I'm going
2:40
to add a directory with demo dir 1 okay
2:46
and I'm going to run as such and then
2:49
the file name I'm going to add and then
2:52
first I need to run this script that is
2:54
I have taught as such I like the file
2:58
name now I'm going to hide you finally
3:00
man sample file 1 so I just showing me
3:05
it is file if I run the commands or if I
3:07
run the script again and if I define
3:10
demo dir 1 so it is showing me it as a
3:13
directory so automatically it will
3:15
detect whether the input I have provided
3:17
whether the name of the father have
3:19
provided whether it is a file or it is a
3:22
directory so this way we can also check
3:24
whether we are using a file or a
3:27
directory same we can also check whether
3:29
we have set any your user IDs or you can
3:34
say group IDs
3:36
or security group IDs for the file or
3:38
folder or not so for that I can just
3:42
change it in such a way I can just make
3:45
it - G so I can provide the entries and
3:54
I can change the echo file and I can
3:57
show it as such else not set actually
4:06
this is not set right
4:14
so we can just I have created e-file as
4:16
we know we haven't set any particular
4:18
permission to our file or directory so I
4:22
just I will run the same AF dot SH and
4:26
the file name and define default name I
4:28
had that was a sample
4:32
file1 so it is not set right so it will
4:36
always check for the SIDS gid whether we
4:40
have defined a security group ID for it
4:42
or not so this we have seen how we can
4:45
define and how we can use the same
4:48
operators that is your file string
4:50
operators even if I want to check for
4:52
the directories I can
4:55
so that I can check for better than
4:57
filename is a directory or it is a file
5:01
so just define D and here we'll set up
5:06
the value is a file or it really tree to
5:09
show me it's a directory or it should
5:14
show me it is a file so let's check
5:20
really command as such I F not as such
5:25
I'm going to define the name demo dir
5:28
one could train me to directory
5:35
well one showing mateesah file so this
5:39
is how generally we can use our file
5:41
string or Praetorians as well
5:42
so using this particular object routes
5:45
are you know it will be very helpful for
5:47
you and when you start you say creating
5:49
the loops or you when you start creating
5:51
your own programs so you can use any of
5:53
these operators over there and it will
5:56
perform it won't get conflicted with
5:57
your other operators if you have already
5:59
used into the same loop so you can use
6:01
any mixture of any operators so here I
6:04
have completed with the operators into
6:05
the next video we are also going to see
6:07
many more things what we can add into
6:10
the shells and defining conditions to
6:13
this shell so for that keep watching
#Computer Science
#Other
#Programming

