The Basics of Manipulating Files from the Command Line
This week’s quick guide is a further practical exploration of the filesystem navigation of our most recent episode. In this one, our goal is instead the crude creation and manipulations of files within that filesystem. We cover a lot of stuff, but seeing someone doing this stuff with your own eyes if often the best way to really get a handle on it. The video:
The Commands We Used
We use mkdir to make a few different directories in this video. Basically it just makes a directory when passed the name. In the example above, that would be
foldername, but that could obviously be anything.
Touch is a simple command that creates a file you specify. Per common convention, your argument will generally be a filename, a period, and a file extension.
cp original.txt copy.txt
Copy a file from an old location to a new one. The biggest gotcha here is if you want to move a folder which has contents, you’ll need to use the
-r flag. The video goes into more detail on this.
mv orginal-name new-name
The move command is easier to understand as “rename”. But it does just that, changes the name of a file or folder when invoked.
rm is how you delete a file. If you need to remove a folder, as with
cp you’ll want to use the
-r flag if that directory has anything inside of it.
Image credit: lyssah
Add a Comment