[Autogenerated] Hello and a really big warm welcome to you
to this plurals site presentation where we take a look at
filtering text files using arc.
My name is andrew Mallet and I'm going to be your instructor
helping you guide you through this module,
a module where we going to take a look at the basics of arc.
We'll see why we're going to use arc.
The advantages that it has over other tools.
We'll see how we can format text output using arc as well as looking
at utilities such as the last log and seeing how we can get a better
output from last log by filtering.
So we see exactly what we want to see.
So this is going to be an absolutely awesome section
to get you up and running with arc.
And like always,
I encourage you to have a system so you're able to
follow through and practice with us.
So the first thing is why would we use arc?
You've probably already heard that it can be complex.
So why on earth would we subject ourselves to such complexity?
Well, we shall begin.
The first thing is that we've got three different blocks that we can use.
We have a begin block or we can use to print headers if nothing else.
So we can have column headers inside of our begin block.
We'll see that we can make do mainly with just our main code block.
And this is where we can print our fields and we also have
an ending block and this is often where we can go through
and add summary information.
This is a very simple way of looking at things,
but it gives you an idea of the three blocks that we work with.
But we're going to concentrate to begin with by taking a look at the main block.
But we will also look at the begin and end blocks within this module.
So our main block we can go through and use arc here.
We're specifying a field separator as a colon and
we're printing out the complete line,
dollar zero and we're working with our E T C plus W D file
because we know this is a file that we're all going to have and
it's going to be readable to everyone.
We can also add a little bit of extra information.
We have a field or a variable that we can use and R for the number of the row.
So we can print the number of the row,
our colon and a space and then our dollar zero,
our complete line, we can also search for information.
So here we've got a regular expression where we're
looking for the line ending in bash.
And again, we're printing the same information.
But instead of expecting maybe to see just two rows,
if we've only got two users with a bash shell,
we'll see the original line number and the data itself.
So we might see something.
I think on my system, it comes out as one and 23 not just one and two,
we can implement our own independent count if we want to
count the records being shown rather than just the line
number from the original file.
Now, we can use print to print our data or we can use print F.
The idea of using print F is it allows me much better formatting that
gives me alignment when we look at our line numbers.
If we've got say one and 23 as our line numbers,
well,
they're not really going to be aligned up so we can make sure
that we align them correctly by using print F.
So we're using two places for a decimal number and then we've
got a string followed by another string,
followed by a new line.
We then pass our variable,
the line number and then our fixed string being our co an and space.
And finally, the third string is being made up of the dollar zero.
Now,
these are just slides and they're going look terrible
if you haven't practiced with arc, then of course,
they're going to look terrible.
However, as soon as we start building this up at the command line,
it's going to become so much more friendly.
So this is why we encourage you to join us in the next module where
we take a few practice lessons with ORK and our,
our main block.