Email Me: lezama at lacartita.com



Getting Started With The Command Line

First of all, what is a ‘command line’? Visually, within a Microsoft Operating System, the command line looks like this:

Pictured is a command line. You can access this by searching ‘CMD’ on your windows search bar.

You can access the command line by typing ‘CMD’ on your Windows Desktop.

As the name implies, a command line is an interface where a user inputs literal commands to accomplish a computing task. The same or similar amount of tasks are often possible via mouse clicks, keyboard commands outside of the CMD screen, etc. Prior to the mouse, the command line was the primary mode of interacting with a computer in the 1970’s prior to the invention of the mouse, point and click method for accessing files in a computer. You may reasonably ask: ‘If people can accomplish basic computing tasks with a simple mouse click and scroll of the screen, then why would anyone use the command line’? The answer is that in modern computing, heavier or more complex tasks can be accomplished more easily by providing specific instructions that can not easily be accomplished with mouse clicks.

Let’s explore a simple and commonly used command to just get started in the command line.

The MV command

The MV command, an often used command for server administrators and grunt level programmers (like me), can help move files around and between computers. Think of programming at this level as steps or tasks accomplished. Individually, this command seems insignificant, but often times, commands are used in harmony with other commands.

Like I alluded to above in the introduction, there is some parity between the tasks accomplished with a mouse and the command line. They are both a type of interface with the computer/server.

For example, one could drag and drop a series of files, one by one, into a different folder based on some criteria. However, let’s say you have a large set of files with some common denominator in terms of text or naming conventions. While you could continue to drag and drop, there are moments in which there are simply too many files to easily view within a screen.

This simple command called ‘mv’ or short for move permits you to move files within a command line interface to other directories.

mv FILENAME somedirectory/

In general, first you type the command type, in this case ‘mv‘, then to the right of that command you specify which files you will move.

mv FILENAME ZIP/

Below is a screenshot of a real world example, a screenshot of a directory that contains these files and the directory where I want to place these files. You may have noticed that there is a ‘*‘ symbol right before zip and then the directory ZIP.

The ‘*‘ symbol is called the Kleene star or wildcard character. The wildcard character matches any character and any number of characters simultaneously. This * character tells the computer to search for a filename with any number and type of strings prior to the string I specified, ‘zip’. It will therefore move all the zip files into the ZIP/ directory.

‘MV’ command where we specify the movement of zip files into ZIP

Here is the literal codeblock:

mv *zip ZIP/

As you can see, the file names that can be moved are ‘g2p-seq2seq-master.zip’, ‘spa-eng.zip’, ‘spanish_g2p.zip’ and ‘NER_news-main.zip’. Its a lot a easier to just type *zip and go about your business that away. Imagine if instead of 4 files it was 400 files you needed to move. In that scenario, therein lies the utility of such a simple command that can “catch-all” the filenames.

Please note, you can also type the file names individually. Here is an example:

mv 'g2p-seq2seq-master.zip' 'spa-eng.zip' 'spanish_g2p.zip' 'NER_news-main.zip' ZIP/

Hopefully, this brief overview of how to use the ‘MV’ command is helpful. Feel free to reach out at lezama@lacartita.com with any questions. Thanks!