1
00:00:06,540 --> 00:00:07,900
In this video
we'll talk about awg.

2
00:00:09,080 --> 00:00:13,070
Org is a great utility for
performing more complex operations on text.

3
00:00:14,089 --> 00:00:17,609
And it has advanced features that make
it into a scripting language by itself.

4
00:00:18,399 --> 00:00:24,424
And when AWG was invented back in the 1970s,
that's exactly what it was, a scripting language, because

5
00:00:24,424 --> 00:00:30,449
that is what was needed in the days that
you couldn't edit text files in full text mode.

6
00:00:31,420 --> 00:00:34,950
Now the advanced features of
AWK are not really needed

7
00:00:34,950 --> 00:00:38,480
anymore. But AWK can make
complex tasks a lot easier.

8
00:00:40,140 --> 00:00:44,840
Let me show you the examples
and let me run them for you.

9
00:00:47,060 --> 00:00:47,990
Starting
with awk.

10
00:00:49,880 --> 00:00:55,640
And then you have the AWK
operation which is always between single quotes.

11
00:00:56,909 --> 00:00:59,759
And I'm going to start by
using print $0 in etc passwd.

12
00:01:04,950 --> 00:01:09,609
Now, $0 is not very meaningful.
It just prints the entire text.

13
00:01:11,469 --> 00:01:16,099
Next example. Org minus uppercase
F colon. It's a field delimiter.

14
00:01:16,760 --> 00:01:23,629
And I want to print
$4 in etc pass WD.

15
00:01:24,170 --> 00:01:26,750
That's the fourth
column in ETC. Passwd.

16
00:01:27,549 --> 00:01:30,129
Now that is not
so spectacular by itself.

17
00:01:30,969 --> 00:01:35,799
But what makes AUG really nice
is that we can look for a

18
00:01:35,799 --> 00:01:40,629
specific text. So here I'm looking
for lines that contain the text Linda

19
00:01:40,629 --> 00:01:45,459
and only if it contains the
text Linda. Then we are printing $4.

20
00:01:46,239 --> 00:01:50,870
And as you can see, 1001
is the user ID of user Linda.

21
00:01:54,280 --> 00:01:58,769
Now another one I'm going to print $1
in case that $3 is greater than $999.

22
00:02:07,659 --> 00:02:07,959
What
is $3?

23
00:02:08,800 --> 00:02:14,330
Well, that contains the user IDs and
for people users, you normally would have a

24
00:02:14,330 --> 00:02:19,860
user ID that is greater than $999.
And $1 contains the usernames. So. So this

25
00:02:19,859 --> 00:02:25,389
line will only print names of users
with the user id greater than 999.

26
00:02:28,490 --> 00:02:31,330
Now you should notice that
awk is not good for sorting.

27
00:02:32,590 --> 00:02:38,596
So a command like sort t
k3 3n etcpasswd is doing a numeric

28
00:02:38,596 --> 00:02:44,603
sort on the third field in
etcpasswd. That's not something that you can

29
00:02:44,603 --> 00:02:50,610
easily do using AWK as a
one liner. Let me show you.

30
00:02:59,069 --> 00:03:02,849
So what do we see here?
Well, you need to look carefully,

31
00:03:02,849 --> 00:03:06,629
but we keep the entire
content of the ETCPass WD field.

32
00:03:07,490 --> 00:03:11,129
But we are sorting it
numerically on the third column.

33
00:03:11,680 --> 00:03:17,564
And that means that the lowest user IDs are
first and the highest user IDs are last. And that's

34
00:03:17,564 --> 00:03:23,449
what you need to know about the things that
you can and cannot do with the ORC utility.
