As I study for Linux+ I am working on writing BASH scripts to help reinforce my memorization. A lot of this stuff is review for me, but it’s still nice to have it fairly present in memory. All things considered, the way Linux handles directories can be a little confusing. A directory is basically a folder of folders, or a shelf in a folder cabinet. However, if you want to create a directory you have to use the “mkdir” function, whereas you can make a file just by providing a file name. Furthermore without the ‘-p’ switch, you need to provide a directory where you want your new directory. The ‘-p’ switch lets you avoid writing ‘/’ in front of the directory name to stick it in the current directory. So the script I wrote does a few things, and helps streamlines things a little more.
The first thing my script does is ask if you want to see the directory in a tree layout. A tree layout is a diagram with directory names, and branches for sub-directories under those directories where appropriate. Sometimes it’ll show content within those directories under the directory name too. The bash command to pull that off is simply “tree”. If you answer with anything other than “yes” or “Yes” it will move onto creating a new directory for you within the current directory. This script will likely be expanded, and change in structure as I get deeper into my Linux+ prep. Anyway, the video below is a recording of the script executing and its source code at the moment.
If you buy anything from Amazon using the link below I may receive a commission from your purchase at Amazon.
Tech Best Sellers at Amazon