[Autogenerated] And look at this.
We have another demonstration coming right up for you a
demonstration where you're going to be able to see how you
can work effectively with aliases.
We're going to create ourselves an alias that cleans the comments from a file.
We're going to be able to list different commented files
and see that it works well for us.
This then is going to help you streamline your command line usage.
This is something you are going to want to implement.
So come on, let's find that command line.
Now you probably already know about aliases.
They really become great shortcuts.
If I look at my current Raspberry pie and let's try and spell alias correctly,
we can see then that I've got some simple aliases here.
So these have probably come from the system,
but there's nothing stopping me creating an alias
that we can use to clean our files.
So I can then go through and define my alias, an alias, clean file.
And this is going to equal and I'm going to define it using the double quotes.
We know that using sd,
we're probably going to be using single quotes to define our expression.
So clean file is going to be equal two said minus upper case E
we then need to define our said expression.
And we're going to say lines to begin with a white space.
But any amount of that white space followed by either
the comment or the end of line marker,
we want to then go through and I haven't defined my regular expression.
So we need to make sure that I put this at the beginning.
So my forward slash and end my forward slash and then
that's my command to delete these lines.
Now, the single quote will end my said expression,
the double quote will end my alias definition.
So now if I type the command alias, we can see that I've got clean file.
And if I go through and look at clean file and then looking in the
said an arc directory for the V host template,
we can see that's printing correctly.
And of course, if I go back and cap that last argument,
escape and dot Remember is a shortcut for the last argument,
we can see that it is still there original with all
of its comments and empty lines.
So we can see how well clean file works for us.
But we've got a different file in there.
If I go through its a cat, my said an org directory.
And let's take a look at our croy dot co.
We've got our time server configuration file in here.
Now, this is a little bit bit more simple.
Yeah, the comments are not indented,
but we can check that it's still going to work with this.
So I can then go through and use clean file an escape and dot And
we can see now how well this has worked for me.
We're able to see from that very long file to something a little
bit less long where we've got 12345 lines.
Don't worry about the way the prompt is pushed right up against the fs.
Just there's no line return after that last line.
Now defining an alias of the command line isn't going to make it persistent.
We need to add it to our log in scripts.
So if we app our key and find our alias and then we can copy the alias command.
So make sure we've got alias and all of the alias definition,
we can put that into our pace buffer and then we can
add it to our dot Bash R C file, which is found in our home directory.
So til dot forward slash dot Bash R C and then inside of our dot Bash R C file,
if we look at moving to the end of the file in VM,
we can use uppercase G lowercase O to insert a new line,
paste that line in and then we're going to be good to go.
So once we've pasted that definition into our dot Bash R C file,
it's going to be executed each time that bas executes.
Now, of course, our alias is defined at the moment.
So let's un alias it, let's delete the alias.
So an alias, clean file, we can check that it's gone by using the alias command.
And to check that our log in script is going to work.
We can use the source command to read in from our home
directory and dot bash our C file,
we can use escape and dot But just use it three times once we've then done that,
we can run the alias command again.
And look,
we've got clean file back and to check that it's been
pasted in in all of its entirety.
Let's check that it works so we can execute then clean file an
or looking at our V host template and again,
its showing in that clean and glorious manner that we had wanted.
So this way we can store our code in an alias and have
that loaded each time we log in.