[Autogenerated] Hello and welcome back and welcome back to this demonstration.
We're using our arc script.
We're going look at how we can pass variables into our YAML
script so we can search for particular users.
We've already seen that whilst it's good,
it may not be that good because it's printing out every
user and we might want a selected user.
So how are we going to do this?
Well, let's take a look now.
This certainly didn't take us long to find a pixel playground
to be working in and we've done really well.
We've been able to print our password file as a
YAML file and that was absolutely amazing.
But of course, the problem that we saw was if we go back and run it again,
it will print out the complete file.
Now, whilst this may be what we want,
surely we should be able to adjust it to print just what we want.
So how can we manage that?
And that is how we need to go through and evaluate
what we need to add to our file.
You might have got a little bit of a clue before
where ID edited the existing script,
but we've got to see how we can use that pattern variable,
but also just look at hard coding values in so we can do that as well.
So let's begin by making our edit now running through
with a control an L to clear my screen, I can go into my favorite text editor,
open up, then my password to YAML file.
And I'm moving down to where my main block is to the left of the brace bracket.
I can go through and search for a line here.
So if I want our hard code it,
I can go through and hit the insert key forward slash.
And I've got a user called pie.
So P I for the user pi save that and then as we go through then and execute it,
we can see I've got the users dictionary and just the user pie.
Now, whilst this is useful,
we don't really want users coming in and editing
this so we can put in a variable.
Let's clear all of that out.
So again to the left of my brace bracket,
I can put dollar zero representing the row matching pattern.
Now, pattern is just the name of a variable.
So I could call it anything.
But it makes sense here that I'm just going to say that dollar zero,
the row matches my pattern that I want.
The match operator is the tilda.
We can go through and save that.
And now to execute at the command line,
we can use minus V for my variable I called it pattern.
So then pattern can be equal to, let's say root.
And we can see our root user if we want to go through
and test a game for another user.
Depending on the users that you have, I can go through and look for pie.
But we could of course, put regular expressions,
not just strings here,
but now we've got a great deal of flexibility built into our org file itself.