1
00:00:01,070 --> 00:00:04,560
If statement in Org is pretty simple.

2
00:00:04,560 --> 00:00:10,280
We are using key vote if followed by condition enclosed in parentheses.

3
00:00:10,650 --> 00:00:16,440
So if that condition is true we are executing commands inside curly braces.

4
00:00:16,920 --> 00:00:23,330
If that condition is not true on inside our section are performed.

5
00:00:23,470 --> 00:00:27,420
The question is how to write conditions in awk.

6
00:00:27,990 --> 00:00:36,030
For example if you want to ask if a value of variable or wire is equal to 5 we need to use double equal

7
00:00:36,030 --> 00:00:43,300
sign and if we for example want to ask a value of variable var is less than 5.

8
00:00:43,530 --> 00:00:54,120
If you just use less than symbol Let's start with looking at our file called table and let's say that

9
00:00:54,120 --> 00:01:04,170
you want to display only a line where the name is equal to Jane and you want to do that using IF statement.

10
00:01:04,170 --> 00:01:13,460
So in the main awk section we ask if value of first field is equal to J.

11
00:01:16,960 --> 00:01:17,740
So if

12
00:01:20,420 --> 00:01:25,100
dollar sign is equal to Jane

13
00:01:29,860 --> 00:01:37,540
and if this condition is true we can print or record all line

14
00:01:41,280 --> 00:01:44,510
and date all line is represented by our Sanzio

15
00:01:48,220 --> 00:01:53,120
and we see the output get.

16
00:01:53,220 --> 00:01:58,600
It is better if use for a body of IF statement curly braces.

17
00:01:58,710 --> 00:02:05,100
It is not needed when you have only one command inside as we have print door Sanzio.

18
00:02:05,430 --> 00:02:12,630
But when you have more commands don't forget to use them.

19
00:02:12,720 --> 00:02:19,920
Now let's say that we want to display from Basford file name and shell for specific user.

20
00:02:19,950 --> 00:02:30,990
For example we found that for use in a root so pass passport file as an input into awk program.

21
00:02:30,990 --> 00:02:39,000
Then we want then we need to change fields separator to com so we can put in specific fields as name

22
00:02:39,030 --> 00:02:44,800
and Chell and then in the main org section we will ask using IF statement.

23
00:02:44,900 --> 00:02:47,820
If first field is equal to route

24
00:02:51,660 --> 00:02:58,780
and if it is equal we can display first field which is name

25
00:03:02,640 --> 00:03:13,570
so print dollar sign one and we can also bring 7 field which is shell and Vissi output.

26
00:03:14,190 --> 00:03:25,230
Been Abeche great but for being sure just check this information using grep command soul got password

27
00:03:25,230 --> 00:03:33,290
file and use grep root and we see that the root shell is truly been Abeche great

28
00:03:36,340 --> 00:03:40,490
we can now project is Else statement.

29
00:03:40,750 --> 00:03:48,590
So at Alice statement after curly braces off if statement

30
00:03:51,590 --> 00:04:01,510
and I'd say that if first field is not equal to the old we will display only first field and not 7 field

31
00:04:03,300 --> 00:04:14,010
so print dollar sign one and we see that it is working perfectly only reward has displayed information

32
00:04:14,130 --> 00:04:16,940
about show great.
