Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
I want us to see how we can go back creating directories that we could put our files into. Directories are essentially folders, but in Unix you are always going to call them directories. So start getting use to that terminology. Instead of calling it a folder, call it a directory. Making a directory is really simple. We just say mkdir, space, and then the name of the directory we want. So I am going to create one called testdir. Hit Return and it created it. It didn't give me any output there. If I do ls-la you'll see that it created. If we come down here at the very last entry, you can see there's a directory because it has this d at the front and that differentiates it from just a standard file which has a dash.
Now if you were to try it again and create the same directory again, you'll get an error letting you know that file exists. It says File exists but it's actually letting us know that the directory exists and then makes sure we don't accidentally overwrite something we don't mean to. Now, if we want to create a directory inside a directory, we can just pass in a path, mkdir testdir/test1. That will create the test1 directory inside testdir. It's just a path, nice and simple. So that will work.
What if I want to go two deep though? If we do test1/test2, now I am saying in addition to going inside the test directory I want you to create two directories. The test1 directory that doesn't exist followed by the test2 to directory that doesn't exist. This won't work. If we try this, it will come back and say, "Oops! Sorry, test1 doesn't exist." In order to make it work, we need to pass in the -p option. p is parents, the parent directories. So create all parent directories as needed until you get to the final directory that I've got.
That's very helpful if we want to create a large directory structure. We can say all right, not just this folder but also these folder is deeper down, create all of them all at once. That's nice handy trick. And if we did ls-la,and we'll type in the directory, testdir/, it will give us the contents of that directory. The other thing I think is kind of nice is the -v option. So we say mkdir -v is for verbose, let's use that p option again, testdir/test1, and let's create another one called test3 that will sit right next to test2.
So there you see it gives me some feedback and lets me know which directories it created. If it created four directories, we would have four entries there, telling us each one that it created. So that's really all to creating directories. Just make sure that you create a directory with the name that doesn't already exist and if you can pass in a full path to the directory that you want, but if some of those directories in that path don't already exist, you will want to also pass in the -p options so it will create them as well.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98450 Viewers
61 Video lessons · 85739 Viewers
71 Video lessons · 69645 Viewers
56 Video lessons · 101971 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.