In this video we'll talk about awg.
Org is a great utility for performing more complex operations on text.
And it has advanced features that make it into a scripting language by itself.
And when AWG was invented back in the 1970s, that's exactly what it was, a scripting language, because
that is what was needed in the days that you couldn't edit text files in full text mode.
Now the advanced features of AWK are not really needed
anymore. But AWK can make complex tasks a lot easier.
Let me show you the examples and let me run them for you.
Starting with awk.
And then you have the AWK operation which is always between single quotes.
And I'm going to start by using print $0 in etc passwd.
Now, $0 is not very meaningful. It just prints the entire text.
Next example. Org minus uppercase F colon. It's a field delimiter.
And I want to print $4 in etc pass WD.
That's the fourth column in ETC. Passwd.
Now that is not so spectacular by itself.
But what makes AUG really nice is that we can look for a
specific text. So here I'm looking for lines that contain the text Linda
and only if it contains the text Linda. Then we are printing $4.
And as you can see, 1001 is the user ID of user Linda.
Now another one I'm going to print $1 in case that $3 is greater than $999.
What is $3?
Well, that contains the user IDs and for people users, you normally would have a
user ID that is greater than $999. And $1 contains the usernames. So. So this
line will only print names of users with the user id greater than 999.
Now you should notice that awk is not good for sorting.
So a command like sort t k3 3n etcpasswd is doing a numeric
sort on the third field in etcpasswd. That's not something that you can
easily do using AWK as a one liner. Let me show you.
So what do we see here? Well, you need to look carefully,
but we keep the entire content of the ETCPass WD field.
But we are sorting it numerically on the third column.
And that means that the lowest user IDs are first and the highest user IDs are last. And that's
what you need to know about the things that you can and cannot do with the ORC utility.