Now let's say you want to copy a file
while renaming it.
This is possible
so let's run
copy
newDirectory
a.out and we're gonna copy it to
newDirectory
b.out
and hit enter.
Now if we run ls on
newDirectory
we see we now have 2 files
and the same thing for the move command so if you want to move a file
and rename it while you
when you move it you have that ability.
So as you'll notice in the, the move command
we do need to give it the file name as well so essentially you are naming it.
So to rename it you would just name it something different.
Well, cool now we've got a,
we've got
three copies of the exact same file
and I'm gonna move it back to my home directory
and then we're going to remove some things.
So,
let's
copy
from newDirectory
a.out
back into
current directory
in the current directory as we can see here is our home directory so
so we're running
relative
commands in here and
they're being run from the home directory.
So if I hit enter here
and run ls,
we can see my a.out file is back where it started.
So,
let's remove a single file
and we're gonna do that,
let's change into newDirectory.
We're gonna remove the b.out file
so
rm
is an abbreviation of remove
and then we're going to
give it our filename that we want to remove.
Now be very careful
when removing files it doesn't prompt you.
If you accidentally add a / to the beginning
its..
I mean you won't have permission you'd have to run a sudo
so I guess it's not that of a big deal. Hit enter.
Now ls and we can see the b.out file has been removed.
Let's go back up at directory,
so let's say we want to remove an entire directory.
So we create a new directory in this video,
let's remove it.
How to do that is
using the remove command but you've got to add
-rf
and then
the directory.
If we run ls again,
we see we no longer have a newDirectory.
Interesting!
Let's list mySecondDirectory there.
So that's what we're going to work with
we're gonna rename this directory
back to myDir just because it's
quicker to type out.
Alright so we've renamed that directory here
so now what we're gonna do is remove,
let's remove all the text files
from this directory.
So we've got two of those,
so we want our a.out file to rename
and how we do this is
it's gonna be using an asterisk in the command and that means everything
and you'll see how this works in the moment. So,
type rm
mydir/
anything.txt.
and what this will do is it will,
it will remove every text file
from this drectory.
Now let's say we had a
a bunch of files let's say main.cpp, main.txt, main.etc
what would we be able to do with that point is type main.*
and so the star means anything right? So this is gonna be main.anything
gets removed but for right now we're working with two .txt files.
*.txt and hit enter
and now run ls on mydir again and we see that it has removed everything
with the .txt extension.